# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
156043 | 2019-10-03T02:12:56 Z | manh9203 | JOIOJI (JOI14_joioji) | C++17 | 49 ms | 7916 KB |
#include<bits/stdc++.h> using namespace std; const long long base = 311; const long long mod = 1311322777; const int N = 2e5 + 5; int n,sum[N][3],ans; map<pair<int,int>,int> check; string s; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> s; s = " " + s; for(int i=1;i<=n;i++){ sum[i][1] = sum[i-1][1]; if(s[i] == 'J') sum[i][1]++; sum[i][2] = sum[i-1][2]; if(s[i] == 'O') sum[i][2]++; sum[i][3] = sum[i-1][3]; if(s[i] == 'I') sum[i][3]++; if(sum[i][1] == sum[i][2] && sum[i][2] == sum[i][3]){ ans = max(ans, i); } pair<int,int> tmp = {sum[i][2]-sum[i][1], sum[i][3]-sum[i][2]}; if(check[tmp] == 0){ check[tmp] = i; }else{ ans = max(ans, i-check[tmp]); } } cout << ans; }
Compilation message
# | 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 | Correct | 2 ms | 380 KB | Output is correct |
10 | Correct | 2 ms | 380 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 | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 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 | 504 KB | Output is correct |
7 | Correct | 3 ms | 476 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 | 9 ms | 1272 KB | Output is correct |
3 | Correct | 14 ms | 2000 KB | Output is correct |
4 | Correct | 25 ms | 3348 KB | Output is correct |
5 | Correct | 38 ms | 5108 KB | Output is correct |
6 | Correct | 48 ms | 5824 KB | Output is correct |
7 | Correct | 49 ms | 6336 KB | Output is correct |
8 | Correct | 47 ms | 5696 KB | Output is correct |
9 | Correct | 49 ms | 5952 KB | Output is correct |
10 | Correct | 47 ms | 5696 KB | Output is correct |
11 | Correct | 38 ms | 7128 KB | Output is correct |
12 | Correct | 31 ms | 4420 KB | Output is correct |
13 | Correct | 26 ms | 3784 KB | Output is correct |
14 | Correct | 42 ms | 7916 KB | Output is correct |
15 | Correct | 26 ms | 3548 KB | Output is correct |