답안 #18713

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
18713 2016-02-14T13:22:27 Z suhgyuho_william JOIOJI (JOI14_joioji) C++
100 / 100
46 ms 6952 KB
#include <stdio.h>
#include <map>

using namespace std;

int N,ans;
char a[200010];
struct data{
	int j,o,i;
	bool operator < (const data x) const{
		if(j != x.j) return j < x.j;
		if(o != x.o) return o < x.o;
		return i < x.i;
	}
	data(int ij,int io,int ii){
		j = ij;
		o = io;
		i = ii;
	}
};
map<data,int> Map;

int main(){
	int i,tmp;
	int cj,co,ci;
	cj = co = ci = 0;
	//freopen("input.txt","r",stdin);

	scanf("%d\n",&N);
	gets(a);
	Map[data(0,0,0)] = 0;
	for(i=1; i<=N; i++){
		if(a[i-1] == 'J'){
			cj++;
		}else if(a[i-1] == 'O'){
			co++;
		}else{
			ci++;
		}
		if(Map.find(data(cj-co,co-ci,ci-cj)) != Map.end()){
            tmp = Map[data(cj-co,co-ci,ci-cj)];
            if(ans < i-tmp) ans = i-tmp;
		}else{
			Map[data(cj-co,co-ci,ci-cj)] = i;
		}
	}
	printf("%d\n",ans);

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1408 KB Output is correct
2 Correct 0 ms 1408 KB Output is correct
3 Correct 0 ms 1408 KB Output is correct
4 Correct 0 ms 1408 KB Output is correct
5 Correct 0 ms 1408 KB Output is correct
6 Correct 0 ms 1408 KB Output is correct
7 Correct 0 ms 1408 KB Output is correct
8 Correct 0 ms 1408 KB Output is correct
9 Correct 0 ms 1408 KB Output is correct
10 Correct 0 ms 1408 KB Output is correct
11 Correct 0 ms 1408 KB Output is correct
12 Correct 0 ms 1408 KB Output is correct
13 Correct 0 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1408 KB Output is correct
2 Correct 0 ms 1408 KB Output is correct
3 Correct 0 ms 1408 KB Output is correct
4 Correct 0 ms 1408 KB Output is correct
5 Correct 0 ms 1408 KB Output is correct
6 Correct 0 ms 1408 KB Output is correct
7 Correct 0 ms 1408 KB Output is correct
8 Correct 0 ms 1408 KB Output is correct
9 Correct 0 ms 1408 KB Output is correct
10 Correct 0 ms 1540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1540 KB Output is correct
2 Correct 7 ms 1936 KB Output is correct
3 Correct 12 ms 2332 KB Output is correct
4 Correct 21 ms 3124 KB Output is correct
5 Correct 30 ms 4180 KB Output is correct
6 Correct 45 ms 4312 KB Output is correct
7 Correct 46 ms 4708 KB Output is correct
8 Correct 46 ms 4180 KB Output is correct
9 Correct 45 ms 4444 KB Output is correct
10 Correct 44 ms 4180 KB Output is correct
11 Correct 35 ms 5896 KB Output is correct
12 Correct 39 ms 2992 KB Output is correct
13 Correct 26 ms 2332 KB Output is correct
14 Correct 34 ms 6952 KB Output is correct
15 Correct 19 ms 1936 KB Output is correct