# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
156044 |
2019-10-03T02:23:37 Z |
souhhcong |
JOIOJI (JOI14_joioji) |
C++14 |
|
65 ms |
7916 KB |
#include <iostream>
#include <map>
#include <stdio.h>
#include <string.h>
using namespace std;
#define cnt_I first
#define cnt_O second.first
#define cnt_J second.second
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
const int N = 2e5+5;
int n, ans = 0;
string s;
iii pref[N];
map<iii,int> check;
int main()
{
cin >> n >> s;
if (s[0] == 'I') pref[0].cnt_I++;
else if (s[0] == 'O') pref[0].cnt_O++;
else pref[0].cnt_J++;
check[pref[0]] = 1;
for (int i = 1; i < n; i++)
{
pref[i] = pref[i-1];
if (s[i] == 'I') pref[i].cnt_I++;
else if (s[i] == 'O') pref[i].cnt_J++;
else pref[i].cnt_O++;
int tmp = min(pref[i].cnt_I,min(pref[i].cnt_O,pref[i].cnt_J));
pref[i].cnt_I -= tmp;
pref[i].cnt_O -= tmp;
pref[i].cnt_J -= tmp;
if (check[pref[i]])
{
ans = max(ans,i+1-check[pref[i]]);
}
else
check[pref[i]] = i+1;
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
252 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 |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
504 KB |
Output is correct |
4 |
Correct |
3 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
504 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
504 KB |
Output is correct |
9 |
Correct |
3 ms |
504 KB |
Output is correct |
10 |
Correct |
3 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
632 KB |
Output is correct |
2 |
Correct |
11 ms |
1272 KB |
Output is correct |
3 |
Correct |
17 ms |
2028 KB |
Output is correct |
4 |
Correct |
33 ms |
3420 KB |
Output is correct |
5 |
Correct |
48 ms |
5128 KB |
Output is correct |
6 |
Correct |
61 ms |
5772 KB |
Output is correct |
7 |
Correct |
65 ms |
6256 KB |
Output is correct |
8 |
Correct |
63 ms |
5640 KB |
Output is correct |
9 |
Correct |
63 ms |
5896 KB |
Output is correct |
10 |
Correct |
64 ms |
5752 KB |
Output is correct |
11 |
Correct |
47 ms |
7176 KB |
Output is correct |
12 |
Correct |
48 ms |
4360 KB |
Output is correct |
13 |
Correct |
35 ms |
3720 KB |
Output is correct |
14 |
Correct |
47 ms |
7916 KB |
Output is correct |
15 |
Correct |
38 ms |
3564 KB |
Output is correct |