Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int t;
- scanf("%d", &t);
- while(t--)
- {
- int x=0, n, v[110], x1;
- char s[30], as[10];
- scanf("%d", &n);
- for(int j=1; j<=n; j++)
- {
- scanf("%s", s);
- if(s=="LEFT")
- {
- x--;
- v[j]=-1;
- }
- else if(s=="RIGHT")
- {
- x++;
- v[j]=1;
- }
- else
- {
- scanf("%s %d", as, &x1);
- x+=v[x1];
- }
- }
- printf("%d\n", x);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement