# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
173430 |
2020-01-04T05:42:29 Z |
easrui |
JOIOJI (JOI14_joioji) |
C++14 |
|
63 ms |
6276 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,int> M;
ll N,J,O,I,cnt;
int ans;
string S;
int main()
{
ios_base::sync_with_stdio(0),cin.tie(0);
cin >> N >> S;
M.insert(make_pair(0,0));
for(int i=0; i<N; i++){
if(S[i]=='J') O--,I--;
if(S[i]=='O') O++;
if(S[i]=='I') I++;
cnt = O*(N+1)+I;
if(M.find(cnt)==M.end()) M.insert(make_pair(cnt,i+1));
}
for(int i=N-1; i>=0; i--){
cnt = O*(N+1)+I;
if(M.find(cnt)!=M.end()) ans = max(ans,i+1-M[cnt]);
if(S[i]=='J') O++,I++;
if(S[i]=='O') O--;
if(S[i]=='I') I--;
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
380 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
380 KB |
Output is correct |
9 |
Correct |
3 ms |
504 KB |
Output is correct |
10 |
Correct |
3 ms |
508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
504 KB |
Output is correct |
2 |
Correct |
11 ms |
1016 KB |
Output is correct |
3 |
Correct |
17 ms |
1528 KB |
Output is correct |
4 |
Correct |
31 ms |
2404 KB |
Output is correct |
5 |
Correct |
49 ms |
3464 KB |
Output is correct |
6 |
Correct |
61 ms |
3460 KB |
Output is correct |
7 |
Correct |
63 ms |
4196 KB |
Output is correct |
8 |
Correct |
62 ms |
3588 KB |
Output is correct |
9 |
Correct |
62 ms |
3844 KB |
Output is correct |
10 |
Correct |
60 ms |
3588 KB |
Output is correct |
11 |
Correct |
48 ms |
5252 KB |
Output is correct |
12 |
Correct |
33 ms |
2436 KB |
Output is correct |
13 |
Correct |
29 ms |
1796 KB |
Output is correct |
14 |
Correct |
52 ms |
6276 KB |
Output is correct |
15 |
Correct |
25 ms |
1292 KB |
Output is correct |