ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#210938 | #2069. 组合技 | rua | 0 | 0ms | 0kb | C++11 | 880b | 2024-08-08 11:57:26 | 2024-08-08 12:40:35 |
answer
#include <bits/stdc++.h>
#define inf INT_MAX
#define NN INT_MIN
typedef long long ll;
using namespace std;
char c[2000005];
int f[2000005], f2[200005];
int main()
{
#ifdef WHX_AK_IOI
// freopen("data.in", "r", stdin);
// freopen("dataout.txt","w",stdout);
#endif
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int ccc, m;
cin >> ccc >> m;
scanf("%s", c + 1);
int n = strlen(c + 1);
// cout << n << endl;
for (int i = 2; i <= n; i++)
{
int j = f[i - 1];
while (j > 0 && c[j + 1] != c[i])
j = f[j];
if (c[j + 1] == c[i] && (j + 1) * 2 < i)
f[i] = j + 1;
else
f[i] = 0;
}
cout << (m - f[n]) / f[n] << endl;
// cout << 111 << endl;
// for (int i = 1; i <= n; i++)
// cout << f[i] << ' ';
// cout << endl;
// system("pause");
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 0
Runtime Error
input:
10 10 BA 476 BA 463 AAABAAX 2044 BBAXXA 934 B 128 BAXBB 886 AXB 784 AXABX 917 XXXABBA 905 XB 343
output:
result:
Subtask #2:
score: 0
Runtime Error
Test #4:
score: 0
Runtime Error
input:
1000 1 BABBXXBXBBABBXBBXXAAAAXBXXBXXXXXAAAAAAXXABBBB 13224
output:
result:
Subtask #3:
score: 0
Skipped
Subtask #4:
score: 0
Skipped
Subtask #5:
score: 0
Skipped