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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
#include <iostream>
#include <vector>
using namespace std;
typedef pair<int, int> pp;
pp king, stone;
char map[8][8];
string dire[8] = {"LT", "T", "RT", "L", "R", "LB", "B", "RB"};
int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
string a, b;
int n;
cin >> a >> b >> n;
int y = a[0] - 'A';
int x = 8 - (a[1] - '0');
king = pp(x, y);
map[x][y] = 'k';
y = b[0] - 'A';
x = 8 - (b[1] - '0');
stone = pp(x, y);
map[x][y] = 's';
while (n--)
{
string dir;
cin >> dir;
for (int i = 0; i < 8; i++)
{
if (dir == dire[i])
{
if (!(kx < 0 || kx >= 8 || ky < 0 || ky >= 8))
{
if (map[kx][ky] == 's')
{
//돌이 있는 곳으로 이동
if (!(sx < 0 || sx >= 8 || sy < 0 || sy >= 8))
{
map[sx][sy] = 's';
stone = pp(sx, sy);
map[kx][ky] = 'k';
king = pp(kx, ky);
}
}
else
{
map[kx][ky] = 'k';
king = pp(kx, ky);
}
}
}
}
}
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
BOJ/C++