답안 #14097

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
14097 2015-05-01T22:47:12 Z comet 볼질 (OJUZ10_ballparade) C++
100 / 100
7 ms 1276 KB
#include<cstdio>
int n,a[50010],b[4],ans;
void push(int k){
	if(k==3){
		ans++;
		return;
	}
	if(b[k+1]==1){
		push(k+1);
	}
	b[k+1]=b[k];
}
void rotate(int k){
	if(k){
		push(0);
	}
	else{
		if(b[3])ans++;
		for(int i=3;i>1;i--)b[i]=b[i-1];
		b[1]=0;
	}
}
void f(){
	int cnt=0;
	for(int i=0;i<n;i++){
		b[0]=1;
		switch(a[i]){
		case 1:
			cnt++;
			if(cnt==4){rotate(1);cnt=0;}
			break;
		case 2:
			cnt=0;
			rotate(1);
			break;
		default:
			rotate(0);
			cnt++;
			if(cnt==4){rotate(1);cnt=0;}
			break;
		}
		//for(int j=0;j<4;j++)printf("%d ",b[j]);
		//printf("cnt=%d ans=%d\n",cnt,ans);
	}
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	f();
	printf("%d",ans);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1276 KB Output is correct
2 Correct 0 ms 1276 KB Output is correct
3 Correct 0 ms 1276 KB Output is correct
4 Correct 3 ms 1276 KB Output is correct
5 Correct 0 ms 1276 KB Output is correct
6 Correct 0 ms 1276 KB Output is correct
7 Correct 0 ms 1276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1276 KB Output is correct
2 Correct 3 ms 1276 KB Output is correct
3 Correct 1 ms 1276 KB Output is correct
4 Correct 0 ms 1276 KB Output is correct
5 Correct 0 ms 1276 KB Output is correct
6 Correct 4 ms 1276 KB Output is correct
7 Correct 0 ms 1276 KB Output is correct
8 Correct 0 ms 1276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1276 KB Output is correct
2 Correct 0 ms 1276 KB Output is correct
3 Correct 4 ms 1276 KB Output is correct
4 Correct 0 ms 1276 KB Output is correct
5 Correct 0 ms 1276 KB Output is correct
6 Correct 6 ms 1276 KB Output is correct
7 Correct 0 ms 1276 KB Output is correct
8 Correct 7 ms 1276 KB Output is correct
9 Correct 7 ms 1276 KB Output is correct
10 Correct 7 ms 1276 KB Output is correct
11 Correct 3 ms 1276 KB Output is correct
12 Correct 0 ms 1276 KB Output is correct
13 Correct 7 ms 1276 KB Output is correct
14 Correct 7 ms 1276 KB Output is correct
15 Correct 0 ms 1276 KB Output is correct