답안 #5891

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
5891 2014-05-21T11:15:47 Z cki86201 JOIOJI (JOI14_joioji) C++
100 / 100
44 ms 6948 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1404 KB Output is correct
2 Correct 0 ms 1404 KB Output is correct
3 Correct 0 ms 1404 KB Output is correct
4 Correct 0 ms 1404 KB Output is correct
5 Correct 0 ms 1404 KB Output is correct
6 Correct 0 ms 1404 KB Output is correct
7 Correct 0 ms 1404 KB Output is correct
8 Correct 0 ms 1404 KB Output is correct
9 Correct 0 ms 1404 KB Output is correct
10 Correct 0 ms 1404 KB Output is correct
11 Correct 0 ms 1404 KB Output is correct
12 Correct 0 ms 1404 KB Output is correct
13 Correct 0 ms 1404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1404 KB Output is correct
2 Correct 0 ms 1404 KB Output is correct
3 Correct 0 ms 1404 KB Output is correct
4 Correct 0 ms 1404 KB Output is correct
5 Correct 0 ms 1404 KB Output is correct
6 Correct 0 ms 1404 KB Output is correct
7 Correct 0 ms 1404 KB Output is correct
8 Correct 0 ms 1404 KB Output is correct
9 Correct 0 ms 1404 KB Output is correct
10 Correct 0 ms 1536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1536 KB Output is correct
2 Correct 4 ms 1932 KB Output is correct
3 Correct 8 ms 2328 KB Output is correct
4 Correct 20 ms 3120 KB Output is correct
5 Correct 32 ms 4176 KB Output is correct
6 Correct 40 ms 4308 KB Output is correct
7 Correct 44 ms 4704 KB Output is correct
8 Correct 40 ms 4176 KB Output is correct
9 Correct 40 ms 4440 KB Output is correct
10 Correct 44 ms 4176 KB Output is correct
11 Correct 24 ms 5892 KB Output is correct
12 Correct 20 ms 2988 KB Output is correct
13 Correct 20 ms 2328 KB Output is correct
14 Correct 36 ms 6948 KB Output is correct
15 Correct 24 ms 1932 KB Output is correct