Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define endl '\n'
- #define sz(x) int(x.size())
- #define all(x) x.begin(), x.end()
- int main() {
- ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
- int test;
- cin >> test;
- while (test--) {
- int n;
- cin >> n;
- int inst[n + 1], p = 0;
- string tmp;
- for (int i = 1; i <= n; i++) {
- cin >> tmp;
- if (tmp == "LEFT") inst[i] = -1;
- if (tmp == "RIGHT") inst[i] = 1;
- if (tmp == "SAME") {
- int x;
- cin >> tmp >> x;
- inst[i] = inst[x];
- }
- p += inst[i];
- }
- cout << p << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement