Advertisement
MiinaMagdy

12503 - Robot Instructions

Sep 1st, 2022
1,016
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define ll long long
  6. #define endl '\n'
  7. #define sz(x) int(x.size())
  8. #define all(x) x.begin(), x.end()
  9.  
  10. int main() {
  11.     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  12.     int test;
  13.     cin >> test;
  14.     while (test--) {
  15.         int n;
  16.         cin >> n;
  17.         int inst[n + 1], p = 0;
  18.         string tmp;
  19.         for (int i = 1; i <= n; i++) { 
  20.             cin >> tmp;
  21.             if (tmp == "LEFT") inst[i] = -1;
  22.             if (tmp == "RIGHT") inst[i] = 1;
  23.             if (tmp == "SAME") {
  24.                 int x;
  25.                 cin >> tmp >> x;
  26.                 inst[i] = inst[x];
  27.             }
  28.             p += inst[i];
  29.         }
  30.         cout << p << endl;
  31.     }
  32. }
  33.  
Tags: UVA CP3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement