-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path24911:Robot Instructions.cpp
45 lines (41 loc) · 1.04 KB
/
24911:Robot Instructions.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
// 24911:Robot Instructions
# include <iostream>
# include <vector>
using namespace std ;
int main() {
int num, instruction ;
string str ;
cin >> num ;
int pos = 0 ;
vector<string> vSet ;
while( num-- ) {
cin >> instruction ;
while( instruction-- ) {
cin >> str ;
if( str == "LEFT" ) {
vSet.push_back( "LEFT" ) ;
pos-- ;
}
else if ( str == "RIGHT" ) {
vSet.push_back( "RIGHT" ) ;
pos++ ;
}
else if( str == "SAME" ) {
cin >> str ;
int i ;
cin >> i ;
if( vSet[i-1] == "LEFT" ) {
vSet.push_back( "LEFT" ) ;
pos-- ;
}
else if( vSet[i-1] == "RIGHT" ) {
vSet.push_back( "RIGHT" ) ;
pos++ ;
}
}
}
cout << pos << endl ;
pos = 0 ;
vSet.clear() ;
}
}