이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |