-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2028A.cpp
More file actions
43 lines (35 loc) · 813 Bytes
/
2028A.cpp
File metadata and controls
43 lines (35 loc) · 813 Bytes
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
#include<bits/stdc++.h>
using namespace std;
string solve(){
int n, a, b; cin >> n >> a >> b;
string str; cin >> str;
int x = 0, y = 0, c = 0;
for(int i = 0; i < str.length(); i++){
if(str[i] == 'N'){
y += 1;
}
else if(str[i] == 'E'){
x += 1;
}
else if(str[i] == 'S'){
y -= 1;
}
else if(str[i] == 'W'){
x -= 1;
}
if(i == str.length() -1){
i = -1;
c++;
}
if(x == a && y == b) return "YES";
if(c == 100) return "NO";
}
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int t; cin >> t;
while(t--){
cout << solve() << endl;;
}
}