# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
251449 |
2020-07-21T09:50:29 Z |
VEGAnn |
Klavir (COCI17_klavir) |
C++14 |
|
183 ms |
28028 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int md = 998244353;
const int M = 1000100;
int n, m, a[M], po[M], ans[M], pf[M];
int mult(int x, int y) { return (1ll * x * y) % md; }
int sum(int x, int y){
x += y;
if (x >= md)
x -= md;
return x;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL
freopen("in.txt","r",stdin);
#endif // _LOCAL
cin >> n >> m;
po[0] = 1;
for (int i = 0; i < m; i++) {
cin >> a[i];
po[i + 1] = mult(po[i], n);
}
pf[0] = 0;
for (int i = 1; i < m; i++){
int j = pf[i - 1];
while (j > 0 && a[j] != a[i])
j = pf[j - 1];
if (a[j] == a[i])
j++;
pf[i] = j;
}
for (int i = 1; i <= m; i++){
ans[i] = sum(ans[pf[i - 1]], po[i]);
cout << ans[i] << " ";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
3192 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
178 ms |
27872 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
183 ms |
27896 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
181 ms |
28028 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |