답안 #156035

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
156035 2019-10-03T01:45:27 Z souhhcong JOIOJI (JOI14_joioji) C++14
95 / 100
61 ms 8564 KB
#include <iostream>
#include <map>
using namespace std;

const int N = 2e5+5;
const long long mpI = 1000000007, mpO = 100000009, 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;
}
# 결과 실행 시간 메모리 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 380 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 376 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 424 KB Output is correct
3 Correct 3 ms 424 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 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 508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 632 KB Output is correct
2 Correct 10 ms 1400 KB Output is correct
3 Correct 15 ms 2168 KB Output is correct
4 Correct 29 ms 3700 KB Output is correct
5 Correct 45 ms 5760 KB Output is correct
6 Correct 57 ms 6536 KB Output is correct
7 Correct 61 ms 7048 KB Output is correct
8 Correct 58 ms 6404 KB Output is correct
9 Correct 58 ms 6792 KB Output is correct
10 Correct 55 ms 6544 KB Output is correct
11 Correct 43 ms 7796 KB Output is correct
12 Correct 34 ms 5128 KB Output is correct
13 Correct 33 ms 4488 KB Output is correct
14 Correct 56 ms 8564 KB Output is correct
15 Correct 31 ms 4232 KB Output is correct