-
Notifications
You must be signed in to change notification settings - Fork 0
/
2021febprob3.cpp
53 lines (43 loc) · 1.08 KB
/
2021febprob3.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <bits/stdc++.h>
using namespace std;
bool lr(char a, char b) { // left is 1, right is 0
if (a == 'N' && b == 'W')
return 1;
else if (a == 'E' && b == 'N')
return 1;
else if (a == 'S' && b == 'E')
return 1;
else if (a == 'W' && b == 'S')
return 1;
else if (a == 'N' && b == 'E')
return 0;
else if (a == 'E' && b == 'S')
return 0;
else if (a == 'S' && b == 'W')
return 0;
else if (a == 'W' && b == 'N')
return 0;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int left = 0;
int right = 0;
string l;
cin >> l;
for (int i = 0; i < l.length()-1; i++) {
if (l[i] != l[i+1] && lr(l[i],l[i+1]))
left++;
else if (l[i] != l[i+1])
right++;
}
if (left > right)
cout << "CCW" << endl;
else
cout << "CW" << endl;
}
return 0;
}