# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
453793 |
2021-08-04T21:43:23 Z |
RGBB |
Savez (COCI15_savez) |
C++14 |
|
110 ms |
2248 KB |
#include <iostream>
#include <bits/stdc++.h>
#include <bitset>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
unordered_map<ll,int>hmap;
int n,length;
ll l,r,base,val;
string input;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n;
for(int i=0;i<n;i++){
cin>>input;
length=input.length();
l=0;
r=0;
base=1;
val=0;
for(int i=0;i<length;i++){
l=(27*l+input[i]-'A'+1)%mod;
r=(r+base*(input[length-i-1]-'A'+1))%mod;
base=(27*base)%mod;
if(l==r&&hmap.find(l)!=hmap.end()&&hmap[l]>val)val=hmap[l];
}
val++;
hmap[l]=val;
}
int output=0;
for(auto&i:hmap)output=max(output,i.second);
cout<<output;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
312 KB |
Output is correct |
3 |
Correct |
2 ms |
320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
1192 KB |
Output is correct |
2 |
Correct |
19 ms |
1228 KB |
Output is correct |
3 |
Correct |
30 ms |
1212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
16 ms |
1228 KB |
Output is correct |
3 |
Correct |
20 ms |
1312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
1224 KB |
Output is correct |
2 |
Correct |
24 ms |
1228 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
1192 KB |
Output is correct |
2 |
Correct |
32 ms |
1284 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
1180 KB |
Output is correct |
2 |
Correct |
33 ms |
1228 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
1312 KB |
Output is correct |
2 |
Correct |
34 ms |
1328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
53 ms |
1440 KB |
Output is correct |
2 |
Correct |
44 ms |
1472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
68 ms |
1560 KB |
Output is correct |
2 |
Correct |
57 ms |
1560 KB |
Output is correct |
3 |
Correct |
110 ms |
2248 KB |
Output is correct |