-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy path7. NASSA's Robot.cpp
44 lines (36 loc) · 998 Bytes
/
7. NASSA's Robot.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
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
int n, miX, miY, maX, maY;
string s;
vector<string> arr;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> s;
arr.push_back(s);
}
for (int i = 0; i <= n - 1; i++) {
miX = miY = maX = maY = 0;
for (int j = 0; j <= arr[i].size() - 1; j++) {
switch (arr[i][j]) {
case 'R':
maX++; miX++; break;
case 'L':
miX--; maX--; break;
case 'U':
maY++; miY++; break;
case 'D':
miY--; maY--; break;
default:
maX++;
miX--;
maY++;
miY--;
}
}
cout << miX << ' ' << miY << ' ' << maX << ' ' << maY << endl;
}
return 0;
}