# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
251453 |
2020-07-21T09:54:46 Z |
VEGAnn |
Klavir (COCI17_klavir) |
C++14 |
|
192 ms |
25976 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int md = int(1e9) + 7;
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] << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
2944 KB |
Output is correct |
2 |
Correct |
165 ms |
24808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
168 ms |
25928 KB |
Output is correct |
2 |
Correct |
160 ms |
24952 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
169 ms |
25976 KB |
Output is correct |
2 |
Correct |
157 ms |
24824 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
192 ms |
25960 KB |
Output is correct |
2 |
Correct |
151 ms |
24824 KB |
Output is correct |