0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 03:11:58 +00:00

B - Go Straight and Turn Right

https://atcoder.jp/contests/abc244/submissions/30274556
This commit is contained in:
Baoshuo Ren 2022-03-20 20:07:15 +08:00
parent 84858f4c68
commit 767bcb2c2c
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

27
AtCoder/ABC244/B/B.cpp Normal file
View File

@ -0,0 +1,27 @@
#include <iostream>
#include <string>
using std::cin;
using std::cout;
const char endl = '\n';
const int mod = 4;
const int to[4][2] = {{1, 0}, {0, -1}, {-1, 0}, {0, 1}};
int n, x, y, d;
std::string s;
int main() {
std::ios::sync_with_stdio(false);
cin >> n >> s;
for (char c : s) {
if (c == 'S') {
x += to[d][0];
y += to[d][1];
} else {
d = ++d % mod;
}
}
cout << x << ' ' << y << endl;
return 0;
}