Submission #20801

#TimeUsernameProblemLanguageResultExecution timeMemory
20801jjwdi0JOIOJI (JOI14_joioji)C++11
100 / 100
43 ms7896 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pr; int N, J, O, ans; char A[200005]; map<pr, int> m; int main() { scanf("%d %s", &N, A); m[pr(0, 0)] = -1; for(int i=0; i<N; i++) { if(A[i] == 'J') J++; if(A[i] == 'O') O++; if(A[i] == 'I') J--, O--; if(m.find(pr(J, O)) != m.end()) ans = max(ans, i - m[pr(J, O)]); else m[pr(J, O)] = i; } printf("%d\n", ans); }

Compilation message (stderr)

joioji.cpp: In function 'int main()':
joioji.cpp:10:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %s", &N, A);
                          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...