QOJ.ac

QOJ

Limite de temps : 1.0 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓

#14728. المطابقة الدائرية

Statistiques

أُعطيت سلسلتين نصيتين $s$ و $t$، تتكون كلتاهما من أحرف صغيرة.

لتكن $s_{l,r}$ هي السلسلة الفرعية من $s$ من حرفها الـ $l$ إلى حرفها الـ $r$ بطول $L = r - l + 1$. نقول إن $t$ تظهر على دائرة $s_{l,r}$ إذا وفقط إذا كان هناك موضع بداية $p$ ($0 \le p < L$) بحيث أنه لكل $0 \le k < |t|$، يكون لدينا $s_{l,r}[(p + k) \bmod L] = t[k]$. إذا كان $L < |t|$، فيُعتبر أن $t$ لا تظهر على دائرة $s_{l,r}$.

احسب كم زوجاً مختلفاً $(l, r)$ يحقق أن $t$ تظهر على دائرة $s_{l,r}$.

الإدخال

يحتوي كل ملف اختبار على عدة حالات اختبار. يحتوي السطر الأول على عدد حالات الاختبار $T$ ($1 \le T \le 2 \times 10^5$). يلي ذلك وصف حالات الاختبار.

يحتوي السطر الأول من كل حالة اختبار على سلسلة نصية $s$ ($1 \le |s| \le 2 \times 10^5$).

يحتوي السطر الثاني على سلسلة نصية $t$ ($1 \le |t| \le 2 \times 10^5$).

من المضمون أن جميع السلاسل النصية تتكون من أحرف صغيرة.

لكل ملف اختبار، من المضمون أن مجموع $|s|$ عبر جميع حالات الاختبار لا يتجاوز $2 \times 10^5$، وأن مجموع $|t|$ عبر جميع حالات الاختبار لا يتجاوز $2 \times 10^5$.

الإخراج

لكل حالة اختبار، اطبع عدداً صحيحاً واحداً في سطر منفرد، يمثل عدد الأزواج $(l, r)$ التي تحقق الشرط.

أمثلة

الإدخال 1

3
cabcccabc
ccabcc
bcdabc
abcd
aaaxaaaxaaa
axaaaxaa

الإخراج 1

3
3
10

الإدخال 2

4
aaaaaaaaa
a
abacab
caba
baaabaab
aabaaab
bbabbbabb
bbbabbb

الإخراج 2

45
4
2
3

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.