# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
4557 |
2013-10-30T06:39:36 Z |
ainta |
Board (CEOI13_board) |
C++ |
|
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{
if(top>2){
st[top-2][1]++;
st[top-1][1]=st[top][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;
}
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2748 KB |
Output is correct |
2 |
Correct |
4 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 |
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2748 KB |
Output is correct |
2 |
Correct |
4 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 |
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
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 |
6 |
Correct |
0 ms |
2748 KB |
Output is correct |