# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
249572 |
2020-07-15T09:52:46 Z |
VEGAnn |
Klavir (COCI17_klavir) |
C++14 |
|
183 ms |
45560 KB |
#include <bits/stdc++.h>
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC optimize("fast-math")
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
using namespace std;
typedef long long ll;
const int M = 1000100;
const int N = 110;
const int md = int(1e9) + 7;
bitset<N> was[M];
int a[M], n, m, ans[M], pf[M], bb[M], summ[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 sub(int x, int y){
x -= y;
if (x < 0)
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;
for (int i = 1; i <= m; i++) {
cin >> a[i];
bb[i - 1] = a[i];
}
ans[0] = 0;
pf[0] = 0;
for (int i = 1; i < m; i++){
int j = pf[i - 1];
while (j > 0 && bb[i] != bb[j])
j = pf[j - 1];
if (bb[i] == bb[j])
j++;
pf[i] = j;
}
summ[0] = 0;
for (int i = 1; i <= m; i++){
ans[i] = mult(sum(ans[i - 1], 1), n);
int id = i - 1;
summ[id] = summ[pf[i - 1]];
ans[i] = sub(ans[i], summ[id]);
was[id] = was[pf[id]];
if (was[id][a[i]]){
summ[id] = sum(summ[id], ans[i]);
int pos = i - 1;
while (a[pos + 1] != a[i]){
pos = pf[pos - 1];
}
summ[id] = sub(summ[id], ans[pos + 1]);
} else {
was[id][a[i]] = 1;
summ[id] = sum(summ[id], ans[i]);
}
// for (int j = 1; j <= n; j++)
// if (a[i] != j){
// int mx = aut[i][j];
// ans[i] = sub(ans[i], ans[mx]);
// }
cout << ans[i] << '\n';
}
return 0;
}
# |
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 |
0 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
0 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
0 ms |
360 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
4856 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
180 ms |
45552 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
171 ms |
45536 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
183 ms |
45560 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |