CF1909G.Pumping Lemma
NOI/NOI+/CTSC
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Tanchiky & Siromaru - Crystal Gravity
⠀
You are given two strings s, t of length n, m, respectively. Both strings consist of lowercase letters of the English alphabet.
Count the triples (x,y,z) of strings such that the following conditions are true:
- s=x+y+z (the symbol + represents the concatenation);
- t=x+k timesy+⋯+y+z for some integer k.
Tanchiky & Siromaru - Crystal Gravity
⠀
给定两个字符串 s 和 t,长度分别为 n 和 m。两个字符串均由小写英文字母组成。
统计满足以下条件的字符串三元组 (x,y,z) 的个数:
- s=x+y+z(其中符号 + 表示字符串连接);
- t=x+k 次y+⋯+y+z,其中 k 为某个整数。
输入格式
The first line contains two integers n and m (1≤n<m≤107) — the length of the strings s and t, respectively.
The second line contains the string s of length n, consisting of lowercase letters of the English alphabet.
The third line contains the string t of length m, consisting of lowercase letters of the English alphabet.
第一行包含两个整数 n 和 m(1≤n<m≤107)—— 分别为字符串 s 和 t 的长度。
第二行包含一个长度为 n 的字符串 s,由小写英文字母组成。
第三行包含一个长度为 m 的字符串 t,由小写英文字母组成。
输出格式
Output a single integer: the number of valid triples (x,y,z).
输出一个整数:满足条件的三元组 (x,y,z) 的个数。
输入输出样例
输入#1
4 8 abcd abcbcbcd
输出#1
1
输入#2
3 5 aaa aaaaa
输出#2
5
输入#3
12 16 abbababacaab abbababababacaab
输出#3
8
说明/提示
In the first test case, the only valid triple is (x,y,z)=("a","bc","d"). In fact,
- "abcd"="a"+"bc"+"d";
- "abcbcbcd"="a"+"bc"+"bc"+"bc"+"d".
In the second test case, there are 5 valid triples:
- (x,y,z)=("","a","aa");
- (x,y,z)=("","aa","a");
- (x,y,z)=("a","a","a");
- (x,y,z)=("a","aa","");
- (x,y,z)=("aa","a","").
In the third test case, there are 8 valid triples:
- (x,y,z)=("ab","ba","babacaab");
- (x,y,z)=("abb","ab","abacaab");
- (x,y,z)=("abba","ba","bacaab");
- (x,y,z)=("ab","baba","bacaab");
- (x,y,z)=("abbab","ab","acaab");
- (x,y,z)=("abb","abab","acaab");
- (x,y,z)=("abbaba","ba","caab");
- (x,y,z)=("abba","baba","caab").
在第一个测试用例中,唯一有效的三元组是 (x,y,z)=("a","bc","d")。事实上,
- "abcd"="a"+"bc"+"d";
- "abcbcbcd"="a"+"bc"+"bc"+"bc"+"d"。
在第二个测试用例中,共有 5 个有效的三元组:
- (x,y,z)=("","a","aa");
- (x,y,z)=("","aa","a");
- (x,y,z)=("a","a","a");
- (x,y,z)=("a","aa","");
- (x,y,z)=("aa","a","")。
在第三个测试用例中,共有 8 个有效的三元组:
- (x,y,z)=("ab","ba","babacaab");
- (x,y,z)=("abb","ab","abacaab");
- (x,y,z)=("abba","ba","bacaab");
- (x,y,z)=("ab","baba","bacaab");
- (x,y,z)=("abbab","ab","acaab");
- (x,y,z)=("abb","abab","acaab");
- (x,y,z)=("abbaba","ba","caab");
- (x,y,z)=("abba","baba","caab")。
输入解题思路,AI测评打分。不知道怎么写?