QOJ.ac

QOJ

時間限制: 10 s 記憶體限制: 256 MB 總分: 100

#23801. แหวน

统计

คุณมีแหวนอยู่ $N$ วง บนแหวนแต่ละวงจะมีสตริงที่ประกอบด้วยตัวอักษรภาษาอังกฤษพิมพ์ใหญ่จำนวน $10$ ตัวสลักอยู่ ตัวอักษรบนแหวนถูกสลักในลักษณะที่จุดเริ่มต้นและจุดสิ้นสุดของสตริงเชื่อมต่อกัน ไม่จำเป็นต้องกังวลเกี่ยวกับการอ่านสตริงที่สลักบนแหวนในลำดับย้อนกลับ

เมื่อกำหนดสตริงที่ต้องการค้นหามาให้ จงเขียนโปรแกรมเพื่อหาว่ามีแหวนกี่วงที่มีสตริงนั้นปรากฏอยู่

ข้อมูลนำเข้า

ข้อมูลนำเข้าประกอบด้วย $2+N$ บรรทัด

บรรทัดที่ $1$ มีสตริงที่ต้องการค้นหาซึ่งประกอบด้วยตัวอักษรภาษาอังกฤษพิมพ์ใหญ่ตั้งแต่ $1$ ตัวถึง $10$ ตัวเขียนอยู่

บรรทัดที่ $2$ มีจำนวนแหวน $N$ ($1 \le N \le 100$) เขียนอยู่

บรรทัดที่ $2+i$ ($1 \le i \le N$) มีสตริงความยาว $10$ ตัวอักษรที่สลักอยู่บนแหวนวงที่ $i$ เขียนอยู่

ข้อมูลส่งออก

แสดงผลจำนวนเต็มที่แทนจำนวนแหวนที่มีสตริงที่ต้องการค้นหาใน $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.