-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUVa12503.cpp
More file actions
57 lines (51 loc) · 1.25 KB
/
UVa12503.cpp
File metadata and controls
57 lines (51 loc) · 1.25 KB
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
55
56
57
//
// main.cpp
// UVa12503
//
// Created by Ricky on 2016/10/16.
// Copyright © 2016年 Ricky. All rights reserved.
//
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
int main(int argc, const char * argv[]) {
// insert code here...
string act;
string temp_c;
int action[100];
int n , datanum , res , temp;
cin >> n ;
for(int i = 0 ; i < n ; i ++)
{
res = 0 ;
cin >> datanum;
getline(cin,act);
for(int j = 0 ; j < datanum ; j ++)
{
getline(cin,act);
if(act == "LEFT")
{
res -= 1;
action[j] = -1;
}
else if(act == "RIGHT")
{
res += 1;
action[j] = 1;
}
else
{
temp_c = act.substr(act.find("AS")+3 , act.length()-1);
//cout << "char = " << temp_c << endl;
temp = atoi(temp_c.c_str());
//cout << "temp" << temp << endl;
action[j] = action[temp-1];
res += action[temp-1];
}
}
cout << res << endl;
}
//cout << "Hello, World!\n";
return 0;
}