답안 #120212

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
120212 2019-06-24T01:07:49 Z dantoh000 JOIOJI (JOI14_joioji) C++14
95 / 100
32 ms 3948 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
unordered_map<ll,int> m;
ll f(int x, int y){
    return (x<<17)^y;
}
int main(){
    int n;
    scanf("%d",&n);
    int ans = 0;
    int a, b;
    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("%d",ans);

}

Compilation message

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("%d",&n);
     ~~~~~^~~~~~~~~
joioji.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %c",&x);
         ~~~~~^~~~~~~~~~
joioji.cpp:17:19: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
             a++; b++;
                  ~^~
joioji.cpp:17:14: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
             a++; b++;
             ~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 1 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 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Incorrect 4 ms 256 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 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 2 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 2 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 1024 KB Output is correct
4 Correct 14 ms 1792 KB Output is correct
5 Correct 21 ms 2216 KB Output is correct
6 Correct 25 ms 2224 KB Output is correct
7 Correct 27 ms 3248 KB Output is correct
8 Correct 25 ms 2216 KB Output is correct
9 Correct 26 ms 2344 KB Output is correct
10 Correct 27 ms 2232 KB Output is correct
11 Correct 31 ms 3464 KB Output is correct
12 Correct 19 ms 1408 KB Output is correct
13 Correct 22 ms 1024 KB Output is correct
14 Correct 32 ms 3948 KB Output is correct
15 Correct 20 ms 768 KB Output is correct