# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
156038 |
2019-10-03T01:51:54 Z |
souhhcong |
JOIOJI (JOI14_joioji) |
C++14 |
|
57 ms |
8584 KB |
#include <iostream>
#include <map>
#include <stdio.h>
#include <string.h>
using namespace std;
const int N = 2e5+5;
const long long mpI = 1e13+7, mpO = 1e13+9, mpJ = -(mpI+mpO);
int n, ans = 0;
string s;
long long pref[N], a[N];
map<long long,int> check;
int main()
{
cin >> n >> s;
for (int i = 0; i < n; i++)
{
if (s[i] == 'I') a[i+1] = mpI;
else if (s[i] == 'O') a[i+1] = mpO;
else a[i+1] = mpJ;
}
for (int i = 1; i <= n; i++)
{
pref[i] = pref[i-1] + a[i];
if (check[pref[i]])
{
ans = max(ans,i-check[pref[i]]);
}
else
check[pref[i]] = i;
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 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 |
Incorrect |
2 ms |
296 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 |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
504 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
504 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 |
4 ms |
632 KB |
Output is correct |
2 |
Correct |
10 ms |
1528 KB |
Output is correct |
3 |
Correct |
15 ms |
2168 KB |
Output is correct |
4 |
Correct |
29 ms |
3756 KB |
Output is correct |
5 |
Correct |
44 ms |
5740 KB |
Output is correct |
6 |
Correct |
56 ms |
6536 KB |
Output is correct |
7 |
Correct |
57 ms |
7252 KB |
Output is correct |
8 |
Correct |
57 ms |
6408 KB |
Output is correct |
9 |
Correct |
56 ms |
6792 KB |
Output is correct |
10 |
Correct |
54 ms |
6508 KB |
Output is correct |
11 |
Correct |
43 ms |
7816 KB |
Output is correct |
12 |
Correct |
35 ms |
5128 KB |
Output is correct |
13 |
Correct |
33 ms |
4488 KB |
Output is correct |
14 |
Correct |
47 ms |
8584 KB |
Output is correct |
15 |
Correct |
31 ms |
4304 KB |
Output is correct |