Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. int main() {
  5.     string frase;
  6.     //vector<int> b;
  7.     int n1, n2, a = 0, b[101], c, i = 0;
  8.     cin >> n1;
  9.  
  10.     while (n1--)
  11.     {
  12.         cin >> n2;
  13.         while (n2--)
  14.  
  15.         {
  16.             if (i == 0) cin.ignore();
  17.             getline(cin, frase);
  18.  
  19.             if (frase == "LEFT")
  20.             {
  21.                 b[i] = 1;
  22.                 a--;
  23.             }
  24.  
  25.             else if (frase == "RIGHT")
  26.             {
  27.                 b[i] = 2;
  28.                 a++;
  29.             }
  30.  
  31.             else
  32.             {
  33.  
  34.                 c = frase[frase.size() - 1] - 48;
  35.                 cout << c << endl;
  36.                 if (b[c] == 1) {
  37.                     b[i] = 1;
  38.                     a--;
  39.                 }
  40.  
  41.                 if (b[c] == 2) {
  42.                     b[i] = 2;
  43.                     a++;
  44.                 }
  45.             }
  46.             i++;
  47.         }
  48.  
  49.         cout << a << endl;
  50.         a = 0;
  51.         i = 0;
  52.         //b.clear();
  53.     }
  54.  
  55.     return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement