Submission #156034

# Submission time Handle Problem Language Result Execution time Memory
156034 2019-10-03T01:44:33 Z souhhcong JOIOJI (JOI14_joioji) C++14
95 / 100
62 ms 8584 KB
#include <iostream>
#include <map>
using namespace std;

const int N = 2e5+5;
const long long mpI = 1000000007, mpO = 998232353, 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 380 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 376 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 552 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 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 4 ms 632 KB Output is correct
2 Correct 10 ms 1532 KB Output is correct
3 Correct 15 ms 2168 KB Output is correct
4 Correct 29 ms 3772 KB Output is correct
5 Correct 45 ms 5700 KB Output is correct
6 Correct 57 ms 6508 KB Output is correct
7 Correct 58 ms 7012 KB Output is correct
8 Correct 57 ms 6408 KB Output is correct
9 Correct 59 ms 6792 KB Output is correct
10 Correct 55 ms 6536 KB Output is correct
11 Correct 43 ms 7740 KB Output is correct
12 Correct 62 ms 5132 KB Output is correct
13 Correct 33 ms 4460 KB Output is correct
14 Correct 48 ms 8584 KB Output is correct
15 Correct 31 ms 4232 KB Output is correct