#include<bits/stdc++.h> using namespace std; int main() { int t; scanf("%d", &t); while(t--) { int n,a; scanf("%d",&n); int j=1, pos=0; int ins[105]={0}; char s[10], b[5]; for(int i=1; i<=n; i++) { scanf("%s",s); if (s[0]=='L') ins[i] = -1; else if (s[0]=='R') ins[i] = 1; else { scanf("%s %d", b, &a); ins[i] = ins[a]; } pos+=ins[i]; } printf("%d\n",pos); } return 0; }
Monday, April 25, 2016
UVA 12503 : Robot Instructions -Solution
Unknown
Studying at Shahjalal University of Science and Technology, Sylhet.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment