# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
5919 |
2014-05-23T02:32:44 Z |
ainta |
Board (CEOI13_board) |
C++ |
|
4 ms |
2764 KB |
#pragma warning(disable:4996)
#include<stdio.h>
struct Stack{
int a, b;
}st[101000];
int top, a[101000], b[101000], c1, c2, Res;
char p[101000];
void ins(int a){
if (st[top].a == a)st[top].b++;
else{
st[++top].a = a; st[top].b = 1;
}
}
void init(){
while (top && !st[top].b)top--;
}
void Del1(){
st[top].b--;
init();
}
int Del2(){
return st[top--].b;
}
void Do(){
int i, ck, t;
top = 0;
scanf("%s", p);
for (i = 0; p[i]; i++){
if (p[i] <= '2'){
ins(p[i] - '0');
continue;
}
if (p[i] == 'U'){
Del1();
continue;
}
if (p[i] == 'L')ck = 1;
else ck = 2;
if (st[top].a != ck){
Del1();
ins(ck);
continue;
}
t = Del2();
Del1();
ins(ck);
st[++top].a = 3 - ck; st[top].b = t;
}
}
int main()
{
Do();
int i, c = 0, t;
for (i = 1; i <= top; i++){
while (st[i].b--)a[++c1] = st[i].a;
}
Do();
for (i = 1; i <= top; i++){
while (st[i].b--)b[++c2] = st[i].a;
}
if (c1 > c2){
Res = c1 - c2; c1 = c2;
}
else Res = c2 - c1;
for (i = 1; i <= c1; i++){
t = c * 2 - a[i] + b[i];
if (t > 3 || t < -3)break;
c = t;
}
Res += (c1 + 1 - i) * 2;
Res += c < 0 ? -c : c;
printf("%d\n", Res);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2764 KB |
Output is correct |
2 |
Correct |
0 ms |
2764 KB |
Output is correct |
3 |
Correct |
0 ms |
2764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2764 KB |
Output is correct |
2 |
Correct |
0 ms |
2764 KB |
Output is correct |
3 |
Correct |
0 ms |
2764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2764 KB |
Output is correct |
2 |
Correct |
0 ms |
2764 KB |
Output is correct |
3 |
Correct |
0 ms |
2764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2764 KB |
Output is correct |
2 |
Correct |
4 ms |
2764 KB |
Output is correct |
3 |
Correct |
0 ms |
2764 KB |
Output is correct |
4 |
Correct |
0 ms |
2764 KB |
Output is correct |
5 |
Correct |
0 ms |
2764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2764 KB |
Output is correct |
2 |
Correct |
0 ms |
2764 KB |
Output is correct |
3 |
Correct |
0 ms |
2764 KB |
Output is correct |
4 |
Correct |
0 ms |
2764 KB |
Output is correct |
5 |
Correct |
0 ms |
2764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2764 KB |
Output is correct |
2 |
Correct |
0 ms |
2764 KB |
Output is correct |
3 |
Correct |
0 ms |
2764 KB |
Output is correct |
4 |
Correct |
0 ms |
2764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2764 KB |
Output is correct |
2 |
Correct |
4 ms |
2764 KB |
Output is correct |
3 |
Correct |
0 ms |
2764 KB |
Output is correct |
4 |
Correct |
0 ms |
2764 KB |
Output is correct |
5 |
Correct |
0 ms |
2764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2764 KB |
Output is correct |
2 |
Correct |
0 ms |
2764 KB |
Output is correct |
3 |
Correct |
0 ms |
2764 KB |
Output is correct |
4 |
Correct |
0 ms |
2764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2764 KB |
Output is correct |
2 |
Correct |
0 ms |
2764 KB |
Output is correct |
3 |
Correct |
0 ms |
2764 KB |
Output is correct |
4 |
Correct |
0 ms |
2764 KB |
Output is correct |
5 |
Correct |
0 ms |
2764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2764 KB |
Output is correct |
2 |
Correct |
0 ms |
2764 KB |
Output is correct |
3 |
Correct |
0 ms |
2764 KB |
Output is correct |
4 |
Correct |
0 ms |
2764 KB |
Output is correct |
5 |
Correct |
0 ms |
2764 KB |
Output is correct |
6 |
Correct |
0 ms |
2764 KB |
Output is correct |