QOJ.ac

QOJ

Limite de temps : 10 s Limite de mémoire : 256 MB Points totaux : 100

#23801. 指輪 (Ring)

Statistiques

あなたは $N$ 個の指輪を持っている.どの指輪にも,アルファベットの大文字 $10$ 文字からなる文字列が刻印されている.指輪には文字列の最初と最後がつながった形で文字が刻印されている.指輪に刻印された文字列を逆順に読む心配はない.

探したい文字列が与えられたとき,その文字列を含む指輪が何個あるかを求めるプログラムを作成せよ.

入力

入力は $2+N$ 行からなる.

$1$ 行目には,$1$ 文字以上 $10$ 文字以下のアルファベットの大文字からなる探したい文字列が書かれている.

$2$ 行目には,指輪の個数 $N$ ($1 \le N \le 100$) が書かれている.

$2+i$ 行目 ($1 \le i \le N$) には,$i$ 個目の指輪に刻印されている $10$ 文字からなる文字列が書かれている.

出力

探したい文字列を含む指輪の個数を表す整数を $1$ 行で出力せよ.

入出力例

入力例 1

ABCD
3
ABCDXXXXXX
YYYYABCDXX
DCBAZZZZZZ

出力例 1

2

入力例 2

XYZ
1
ZAAAAAAAXY

出力例 2

1

入力例 3

PQR
3
PQRAAAAPQR
BBPQRBBBBB
CCCCCCCCCC

出力例 3

2

注記

入力例 $2$ の指輪には XYZ という文字列が $1$ つ含まれている.これは,指輪の文字列の最初と最後がつながっているためである.

入力例 $3$ の $1$ 個目の指輪には PQR という文字列が $2$ つ含まれており,$2$ 個目の指輪には PQR という文字列が $1$ 個含まれており,$3$ 個目の指輪には PQR という文字列が含まれていない.そのため PQR という文字列が含まれている指輪の数は $2$ 個となる.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.