-
Notifications
You must be signed in to change notification settings - Fork 0
/
12503.cpp
54 lines (50 loc) · 778 Bytes
/
12503.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
43
44
45
46
47
48
49
50
51
52
53
54
#include<iostream>
#include<string>
#include<stdlib.h>
using namespace std;
int main()
{
int i,t;
cin>>t;
str ins[t];
for(i=0;i<t;i++)
{
cin>>ins[i];
}
string s="";
for(int k=0;k<t;k++)
{ char valstr[3];
s=ins[k];
if(s=="LEFT")
{;}
else if(s=="RIGHT")
{;}
else
{ int j=0;
for(i=8;i<='\0';i++)
{
valstr[j]=s[i];
j++;
}
int val=atoi(valstr);
ins[k+1]=ins[val];
}
}
int a=0;
string al="LEFT";
string bl="RIGHT";
int b=0;
for(i=0;i<t;i++)
{
if(ins[t]==al)
{
a++;
}
if(ins[t]==bl)
{
b++;
}
}
cout<<b-a;
return 0;
}