Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- using namespace std;
- void DirectionalMove () {
- ll t, garbage, dir = 90;
- string x;
- cin >> t;
- while (t--) {
- dir = 90;
- cin >> garbage;
- cin >> x;
- for (ll i = 0; i < garbage; i++) {
- if (x[i] == '0') {
- dir += 90;
- } else if (x[i] == '1') {
- dir -= 90;
- }
- }
- if (dir < 0 and dir >= -360) {
- dir += 360;
- }
- if (dir < -360) {
- dir *= -1;
- dir -= 360;
- }
- if (dir >= 360) {
- dir %= 360;
- }
- if (dir % 360 == 0 or dir == 0) {
- cout << "N"<<endl;
- } else if (dir % 270 == 0) {
- cout << "W"<<endl;
- } else if (dir % 180 == 0) {
- cout << "S"<<endl;
- } else if (dir % 90 == 0) {
- cout << "E"<<endl;
- }
- }
- }
- int main() {
- DirectionalMove();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement