mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-10 02:38:49 +00:00
B - Go Straight and Turn Right
https://atcoder.jp/contests/abc244/submissions/30274556
This commit is contained in:
parent
84858f4c68
commit
767bcb2c2c
27
AtCoder/ABC244/B/B.cpp
Normal file
27
AtCoder/ABC244/B/B.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user