-
Notifications
You must be signed in to change notification settings - Fork 0
/
UVa12503.cpp
42 lines (40 loc) · 1.01 KB
/
UVa12503.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include<bits/stdc++.h>
int main(){
int n,t;
char ins[100];
scanf("%d", &t);
int i,j,temp,row[110];
for(i=1;i<=t;i++){
scanf("%d", &n);
int k,pos = 0;
for(k=1;k<=n;k++){
scanf("%s", &ins);
getchar();
if(ins[0]=='L'){
row[k]=1;
pos--;
//printf("pos in L : %d\n",pos);
}
else if(ins[0]=='R'){
row[k] = 0;
pos++;
//printf("pos in R : %d\n",pos);
}
else{
scanf("%*s %d", &temp);
if(row[temp]==1){
pos--;
row[k]=1;
}
else if(row[temp]==0){
pos++;
row[k] = 0;
}
//printf("pos in S : %d\n",pos);
}
}
printf("%d\n",pos);
pos = 0;
}
return 0;
}