# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
43524 |
2018-03-17T10:30:03 Z |
ffresh |
JOIOJI (JOI14_joioji) |
C++14 |
|
96 ms |
12304 KB |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+15,M = 3;
int convert(char x){
if(x=='I')return 0;
else if(x=='O')return 1;
return 2;
}
int sum[N][M];
int Hash[N][M];
#define mp make_pair
bool check(pair<int,pair<int,int> > t){
if(t.first== t.second.first && t.first== t.second.second)return 1;
return 0;
}
int main(){
//freopen("input.txt","r",stdin);
int n;
string s;
cin>>n;
cin>>s;
for(int i=1;i<=(int)s.size();++i){
for (int j = 0; j < M; ++j){
sum[i][j]= sum[i-1][j];
}
int x =convert(s[i-1]);
++sum[i][x];
}
for(int k=0;k<M;++k){
for(int i=1;i<=3;++i){
int pos=1;
for(int j=i;j<=n;j+=3,++pos){
Hash[j][k]= sum[j][k]-pos;
}
}
}
/*cout<<sum[1][2]<<" "<<sum[7][2]<<endl;
cout<<Hash[1][2]<<" "<<Hash[7][2]<<endl;
cout<<Hash[1][1]<<" "<<Hash[7][1]<<endl;
cout<<Hash[1][0]<<" "<<Hash[7][0]<<endl;*/
int ret=0;
for(int i=1;i<=3;++i){
set<pair<pair<int,pair<int,int> >,int> >s;
for(int j=i;j<=n;j+=3){
s.insert( mp( mp(Hash[j][0],mp(Hash[j][1],Hash[j][2]) ),j));
}
for(set<pair<pair<int,pair<int,int> >,int> >::iterator it = s.begin();it!= s.end();){
auto temp = *it;
auto z = temp.first;
set<pair<pair<int,pair<int,int> >,int> >::iterator jt;
int maxi = temp.second;
for(jt= it;jt!= s.end();++jt){
auto T = *jt;
if(T.first!= z)break;
maxi = T.second;
}
it = jt;
if( sum[maxi][0]-sum[temp.second][0]== (maxi-temp.second)/3){
ret= max(ret, maxi-temp.second);
}
}
}
cout<<ret<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
2 ms |
592 KB |
Output is correct |
4 |
Correct |
2 ms |
636 KB |
Output is correct |
5 |
Correct |
2 ms |
636 KB |
Output is correct |
6 |
Correct |
2 ms |
636 KB |
Output is correct |
7 |
Correct |
2 ms |
636 KB |
Output is correct |
8 |
Correct |
2 ms |
636 KB |
Output is correct |
9 |
Incorrect |
2 ms |
648 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
656 KB |
Output is correct |
2 |
Correct |
2 ms |
788 KB |
Output is correct |
3 |
Correct |
2 ms |
840 KB |
Output is correct |
4 |
Correct |
3 ms |
844 KB |
Output is correct |
5 |
Correct |
2 ms |
848 KB |
Output is correct |
6 |
Correct |
2 ms |
852 KB |
Output is correct |
7 |
Correct |
2 ms |
892 KB |
Output is correct |
8 |
Correct |
3 ms |
900 KB |
Output is correct |
9 |
Correct |
3 ms |
900 KB |
Output is correct |
10 |
Correct |
2 ms |
904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1180 KB |
Output is correct |
2 |
Correct |
11 ms |
2112 KB |
Output is correct |
3 |
Correct |
17 ms |
3160 KB |
Output is correct |
4 |
Correct |
37 ms |
5532 KB |
Output is correct |
5 |
Correct |
58 ms |
7988 KB |
Output is correct |
6 |
Correct |
96 ms |
10444 KB |
Output is correct |
7 |
Correct |
85 ms |
10616 KB |
Output is correct |
8 |
Correct |
84 ms |
10812 KB |
Output is correct |
9 |
Correct |
81 ms |
11008 KB |
Output is correct |
10 |
Correct |
96 ms |
11204 KB |
Output is correct |
11 |
Correct |
51 ms |
11204 KB |
Output is correct |
12 |
Correct |
52 ms |
11204 KB |
Output is correct |
13 |
Correct |
57 ms |
11392 KB |
Output is correct |
14 |
Correct |
46 ms |
11392 KB |
Output is correct |
15 |
Correct |
56 ms |
12304 KB |
Output is correct |