-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1574.cpp
More file actions
54 lines (51 loc) · 736 Bytes
/
1574.cpp
File metadata and controls
54 lines (51 loc) · 736 Bytes
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
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
int n,num,in,i,j=0,val=0,vet[100];
string st1;
scanf("%d",&n);
while(n){
for(i=0;i<100;i++)
vet[i]=0;
scanf("%d",&in);
while(in){
cin>>st1;
if(st1=="LEFT"){
vet[j]=-1;
}else{
if(st1=="RIGHT"){
vet[j]=-2;
}else{
cin>>st1;
cin>>num;
vet[j]=num;
}
}
j++;
in--;
}
for(i=0;i<100;i++){
if(vet[i]!=0 && vet[i]!=-1 && vet[i]!=-2){
while(vet[vet[i]-1]!=-1 && vet[vet[i]-1]!=-2){
vet[i]=vet[vet[i]-1];
}
vet[i]=vet[vet[i]-1];
}
if(vet[i]==0){
break;}
else{
if(vet[i]==-1){
val--;
}else{
val++;
}
}
}
printf("%d\n",val);
val=0;
j=0;
n--;
}
return 0;
}