답안 #120217

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
120217 2019-06-24T01:11:47 Z dantoh000 JOIOJI (JOI14_joioji) C++14
100 / 100
30 ms 3984 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
unordered_map<int,int> m;
int f(int x, int y){
    return (x<<17)^y;
}
main(){
    int n;
    scanf("%lld",&n);
    int ans = 0;
    int a = 0, b= 0;
    m[0] = -1;
    for (int i = 0; i < n; i++){
        char x;
        scanf(" %c",&x);
        if (x == 'J'){
            a++; b++;
        }
        else if (x == 'O') a--;
        else if (x == 'I') b--;
        int k = f(a,b);
        if (m[k] == 0){
            m[k] = i;
        }
        else{
            ans = max(ans,i-m[k]);
        }
    }
    printf("%lld",ans);
}

Compilation message

joioji.cpp:8:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
joioji.cpp: In function 'int main()':
joioji.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
     ~~~~~^~~~~~~~~~~
joioji.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %c",&x);
         ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 512 KB Output is correct
2 Correct 5 ms 768 KB Output is correct
3 Correct 8 ms 1004 KB Output is correct
4 Correct 14 ms 1792 KB Output is correct
5 Correct 21 ms 2224 KB Output is correct
6 Correct 25 ms 2216 KB Output is correct
7 Correct 28 ms 3240 KB Output is correct
8 Correct 26 ms 2088 KB Output is correct
9 Correct 25 ms 2368 KB Output is correct
10 Correct 24 ms 2216 KB Output is correct
11 Correct 30 ms 3472 KB Output is correct
12 Correct 21 ms 1280 KB Output is correct
13 Correct 19 ms 1024 KB Output is correct
14 Correct 28 ms 3984 KB Output is correct
15 Correct 19 ms 768 KB Output is correct