Advertisement
ec1117

Untitled

Mar 14th, 2022
965
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <fstream>
  4. #include <set>
  5. #include <cstring>
  6. #include <map>
  7. #include <string>
  8. #include <utility>
  9. using namespace std;
  10. int main() {
  11.     map<string, int> turns;
  12.     turns.insert(pair<string, int>("NE", 1));
  13.     turns.insert(pair<string, int>("SW", 1));
  14.     turns.insert(pair<string, int>("ES", 1));
  15.     turns.insert(pair<string, int>("WN", 1));
  16.     turns.insert(pair<string, int>("EN", -1));
  17.     turns.insert(pair<string, int>("WS", -1));
  18.     turns.insert(pair<string, int>("SE", -1));
  19.     turns.insert(pair<string, int>("NW", -1));
  20.     int n;
  21.     cin >> n;
  22.     for (int i = 0; i < n; i++) {
  23.         int counter = 0;
  24.         string s;
  25.         cin >> s;
  26.         for (int j = 0; j < s.length() - 1; j++) {
  27.             string a = s.substr(j, 2);
  28.             if (turns.count(a))counter += turns[a];
  29.         }
  30.         if (counter > 0) cout << "CW" << endl;
  31.         else cout << "CCW" << endl;
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement