답안 #4555

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
4555 2013-10-29T12:13:18 Z ainta 게임판 (CEOI13_board) C++
50 / 100
4 ms 2748 KB
#include<stdio.h>
int st[100100][2],top,i,x,a[100100],b[100100],c1,c2;
char p[101000];
void Do(){
	for(i=0;p[i];i++){
		if(p[i]<='2'){
			p[i]-='0';
			if(st[top][0]==p[i])st[top][1]++;
			else{
				st[++top][0]=p[i];
				st[top][1]=1;
			}
			continue;
		}
		if(p[i]=='U'){
			st[top][1]--;
			if(!st[top][1])top--;
			continue;
		}
		if(p[i]=='L')x=1;
		else x=2;
		if(x==st[top][0]){
			if(st[top-1][1]>1){
				st[top-1][1]--;
				st[top+1][0]=3-x;
				st[top+1][1]=st[top][1];
				st[top][0]=x;
				st[top][1]=1;
				top++;
			}
			else{
				st[top-1][0]=x;
				st[top][0]=3-x;
			}
			continue;
		}
		if(st[top][1]>1){
			st[top][1]--;
			st[++top][0]=x;
			st[top][1]=1;
		}
		else{
			if(top>1){
				st[top-1][1]++;
				top--;
			}
			else st[top][0]=x;
		}
	}
}
int main()
{
	int Res,x=0;
	scanf("%s",p);
	Do();
	for(i=1;i<=top;i++)
		while(st[i][1]--)a[c1++]=st[i][0];
	top=0;
	scanf("%s",p);
	Do();
	for(i=1;i<=top;i++)
		while(st[i][1]--)b[c2++]=st[i][0];
	if(c1>c2)Res=c1-c2,c1=c2;
	else Res=c2-c1;
	for(i=0;i<c1;i++){
		x*=2;
		x+=(a[i]-b[i]);
		if(x>3 || x<-3){
			x-=(a[i]-b[i]);
			x/=2;
			Res+=(c1-i)*2;
			break;
		}
	}
	if(x<0)x=-x;
	Res+=x;
	printf("%d\n",Res);
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2748 KB Output is correct
2 Correct 0 ms 2748 KB Output is correct
3 Correct 0 ms 2748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2748 KB Output is correct
2 Correct 0 ms 2748 KB Output is correct
3 Correct 0 ms 2748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2748 KB Output is correct
2 Correct 4 ms 2748 KB Output is correct
3 Incorrect 0 ms 2748 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2748 KB Output is correct
2 Correct 0 ms 2748 KB Output is correct
3 Correct 0 ms 2748 KB Output is correct
4 Correct 0 ms 2748 KB Output is correct
5 Correct 0 ms 2748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2748 KB Output is correct
2 Incorrect 4 ms 2748 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2748 KB Output is correct
2 Correct 0 ms 2748 KB Output is correct
3 Correct 0 ms 2748 KB Output is correct
4 Correct 0 ms 2748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2748 KB Output is correct
2 Correct 0 ms 2748 KB Output is correct
3 Correct 0 ms 2748 KB Output is correct
4 Correct 0 ms 2748 KB Output is correct
5 Correct 0 ms 2748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2748 KB Output is correct
2 Incorrect 0 ms 2748 KB Output isn't correct
3 Halted 0 ms 0 KB -