답안 #18712

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
18712 2016-02-14T12:46:41 Z kdh9949 JOIOJI (JOI14_joioji) C++
100 / 100
45 ms 6952 KB
#include <cstdio>
#include <map>
using namespace std;
typedef long long ll;

int n, J, O, I, ans;
ll k;
char str[200010];
map<ll, int> mp;

int main(){
    scanf("%d%s", &n, str + 2);
    J = O = I = n;
    mp[(4ll * n * n) * J + (2ll * n) * O + I] = 1;
    for(int i = 2; i < n + 2; i++){
        str[i] == 'J' ? J++ : str[i] == 'O' ? O++ : I++;
        k = (4ll * n * n) * n + (2ll * n) * (O + (n - J)) + (I + (n - J));
        if(!mp[k]) mp[k] = i;
        else ans = max(ans, i - mp[k]);
    }
    printf("%d", ans);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1408 KB Output is correct
2 Correct 0 ms 1408 KB Output is correct
3 Correct 0 ms 1408 KB Output is correct
4 Correct 0 ms 1408 KB Output is correct
5 Correct 0 ms 1408 KB Output is correct
6 Correct 0 ms 1408 KB Output is correct
7 Correct 0 ms 1408 KB Output is correct
8 Correct 0 ms 1408 KB Output is correct
9 Correct 0 ms 1408 KB Output is correct
10 Correct 0 ms 1408 KB Output is correct
11 Correct 0 ms 1408 KB Output is correct
12 Correct 0 ms 1408 KB Output is correct
13 Correct 0 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1408 KB Output is correct
2 Correct 0 ms 1408 KB Output is correct
3 Correct 1 ms 1408 KB Output is correct
4 Correct 1 ms 1408 KB Output is correct
5 Correct 1 ms 1408 KB Output is correct
6 Correct 0 ms 1408 KB Output is correct
7 Correct 0 ms 1408 KB Output is correct
8 Correct 0 ms 1408 KB Output is correct
9 Correct 0 ms 1408 KB Output is correct
10 Correct 1 ms 1540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1540 KB Output is correct
2 Correct 6 ms 1936 KB Output is correct
3 Correct 11 ms 2332 KB Output is correct
4 Correct 19 ms 3124 KB Output is correct
5 Correct 32 ms 4180 KB Output is correct
6 Correct 37 ms 4312 KB Output is correct
7 Correct 45 ms 4708 KB Output is correct
8 Correct 40 ms 4180 KB Output is correct
9 Correct 44 ms 4444 KB Output is correct
10 Correct 43 ms 4180 KB Output is correct
11 Correct 28 ms 5896 KB Output is correct
12 Correct 19 ms 2992 KB Output is correct
13 Correct 20 ms 2332 KB Output is correct
14 Correct 32 ms 6952 KB Output is correct
15 Correct 19 ms 1936 KB Output is correct