#include <cstdio>
#include <vector>
#include <queue>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include <map>
#define ll long long
using namespace std;
int N,ans;
int board[20][20];
pair<int,int> king;
pair<int,int> stone;
int dc[8] = {1, -1, 0, 0, 1, -1 ,1, -1};
int dr[8] = {0, 0, 1, -1, -1, -1, 1, 1};
int changeDir(string s)
{
int dir;
if(s == "R") dir = 0;
else if(s == "L") dir = 1;
else if(s == "B") dir = 2;
else if(s == "T") dir = 3;
else if(s == "RT") dir = 4;
else if(s == "LT") dir = 5;
else if(s == "RB") dir = 6;
else if(s == "LB") dir = 7;
return dir;
}
int changePosInt(char c)
{
if(c == 'A') return 1;
else if(c == 'B') return 2;
else if(c == 'C') return 3;
else if(c == 'D') return 4;
else if(c == 'E') return 5;
else if(c == 'F') return 6;
else if(c == 'G') return 7;
return 8;
}
string changePosChar(int n){
if(n == 1) return "A";
else if(n == 2) return "B";
else if(n == 3) return "C";
else if(n == 4) return "D";
else if(n == 5) return "E";
else if(n == 6) return "F";
else if(n == 7) return "G";
return "H";
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
string sk, ss;
cin >> sk >> ss >> N;
king = {9-(sk[1]-'0'), changePosInt(sk[0])};
stone = {9-(ss[1]-'0'), changePosInt(ss[0])};
for(int i=0;i<N;i++)
{
string c;
cin >> c;
int dir = changeDir(c);
int k_nr = king.first + dr[dir];
int k_nc = king.second + dc[dir];
if(k_nr<1 or k_nc<1 or k_nr>8 or k_nc>8) continue;
if(k_nr == stone.first and k_nc == stone.second){
int s_nr = stone.first + dr[dir];
int s_nc = stone.second + dc[dir];
if(s_nr<1 or s_nc<1 or s_nr>8 or s_nc>8) continue;
stone = {s_nr, s_nc};
}
king = {k_nr, k_nc};
}
sk = changePosChar(king.second) + to_string(9-king.first);
ss = changePosChar(stone.second) + to_string(9-stone.first);
cout << sk << '\n' << ss;
return 0;
}
- 주의
행의 방향
이 8
과 1
이 보통 풀던 방향
과 다르다는 것
을 인지
해야한다