Submission #5891

#TimeUsernameProblemLanguageResultExecution timeMemory
5891cki86201JOIOJI (JOI14_joioji)C++98
100 / 100
44 ms6948 KiB
#include<stdio.h> #include<map> using namespace std; #define X first #define Y second typedef pair<int,int> Pi; char ch[200020]; int n, ans; map <Pi, int> M; int main(){ scanf("%d%s",&n,ch); Pi now = Pi(0,0); M[Pi(0,0)] = -1; for(int i=0;ch[i];i++){ if(ch[i] == 'J')--now.X, --now.Y; else if(ch[i] == 'I')++now.X; else ++now.Y; if(M.find(now) != M.end())ans = max(ans, i - M[now]); else M[now] = i; } printf("%d",ans); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...