# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
100843 |
2019-03-14T21:03:20 Z |
dalgerok |
Savez (COCI15_savez) |
C++17 |
|
166 ms |
65332 KB |
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 505, M = 2e6 + 5, MOD1 = 1e9 + 1337, MOD2 = 999888777;
int n, p1[M], p2[M], ans;
map < pair < int, int >, int > dp;
vector < int > h1[N], h2[N];
string s[N];
inline pair < int, int > get(int i, int l, int r){
return make_pair(
(h1[i][r] - h1[i][l - 1] + MOD1) % MOD1 * p1[M - r] % MOD1,
(h2[i][r] - h2[i][l - 1] + MOD2) % MOD2 * p2[M - r] % MOD2
);
}
main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
p1[0] = p2[0] = 1;
for(int i = 1; i < M; i++){
p1[i] = p1[i - 1] * 59 % MOD1;
p2[i] = p2[i - 1] * 45 % MOD2;
}
cin >> n;
for(int i = 1; i <= n; i++){
cin >> s[i];
int sz = (int)s[i].size();
h1[i].resize(sz + 2);
h2[i].resize(sz + 2);
for(int j = 1; j <= sz; j++){
h1[i][j] = (h1[i][j - 1] + s[i][j - 1] * p1[j]) % MOD1;
h2[i][j] = (h2[i][j - 1] + s[i][j - 1] * p2[j]) % MOD2;
}
int mx = 0;
for(int j = 1; j <= sz; j++){
auto it1 = get(i, 1, j),
it2 = get(i, sz - j + 1, sz);
if(it1 == it2){
mx = max(mx, dp[it1]);
}
}
dp[get(i, 1, sz)] = mx + 1;
ans = max(ans, mx + 1);
}
cout << ans;
}
Compilation message
savez.cpp:21:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
31612 KB |
Output is correct |
2 |
Correct |
33 ms |
31708 KB |
Output is correct |
3 |
Correct |
33 ms |
31736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
31736 KB |
Output is correct |
2 |
Correct |
33 ms |
31736 KB |
Output is correct |
3 |
Correct |
36 ms |
33144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
150 ms |
48516 KB |
Output is correct |
2 |
Correct |
166 ms |
48440 KB |
Output is correct |
3 |
Correct |
152 ms |
49828 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
32888 KB |
Output is correct |
2 |
Correct |
84 ms |
47864 KB |
Output is correct |
3 |
Correct |
117 ms |
48504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
74 ms |
65332 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
71 ms |
64056 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
72 ms |
63608 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
75 ms |
63480 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
72 ms |
63352 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
75 ms |
63224 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |