BOJ - 1063 - 킹
Updated:
Alphabet = 'ABCDEFGH'
def solution():
A, B, T = map(str, input().split(' '))
King = [8 - int(A[1]), Alphabet.index(A[0])]
Stone = [8 - int(B[1]), Alphabet.index(B[0])]
for i in range(int(T)):
command = str(input())
if command == 'R':
if King[1] < 7:
if King[1] + 1 == Stone[1] and King[0] == Stone[0]:
if Stone[1] < 7:
King[1] += 1
Stone[1] += 1
else:
King[1] += 1
elif command == 'L':
if King[1] > 0:
if King[1] - 1 == Stone[1] and King[0] == Stone[0]:
if Stone[1] > 0:
King[1] -= 1
Stone[1] -= 1
else:
King[1] -= 1
elif command == 'T':
if King[0] > 0:
if King[0] - 1 == Stone[0] and King[1] == Stone[1]:
if Stone[0] > 0:
King[0] -= 1
Stone[0] -= 1
else:
King[0] -= 1
elif command == 'B':
if King[0] < 7:
if King[0] + 1 == Stone[0] and King[1] == Stone[1]:
if Stone[0] < 7:
King[0] += 1
Stone[0] += 1
else:
King[0] += 1
elif command == 'RT':
if King[1] < 7 and King[0] > 0:
if King[1] + 1 == Stone[1] and King[0] - 1 == Stone[0]:
if Stone[1] < 7 and Stone[0] > 0:
King[1] += 1
Stone[1] += 1
King[0] -= 1
Stone[0] -= 1
else:
King[1] += 1
King[0] -= 1
elif command == 'LT':
if King[1] > 0 and King[0] > 0:
if King[1] - 1 == Stone[1] and King[0] - 1 == Stone[0]:
if Stone[1] > 0 and Stone[0] > 0:
King[1] -= 1
Stone[1] -= 1
King[0] -= 1
Stone[0] -= 1
else:
King[1] -= 1
King[0] -= 1
elif command == 'RB':
if King[1] < 7 and King[0] < 7:
if King[1] + 1 == Stone[1] and King[0] + 1 == Stone[0]:
if Stone[1] < 7 and Stone[0] < 7:
King[1] += 1
Stone[1] += 1
King[0] += 1
Stone[0] += 1
else:
King[1] += 1
King[0] += 1
elif command == 'LB':
if King[1] > 0 and King[0] < 7:
if King[1] - 1 == Stone[1] and King[0] + 1 == Stone[0]:
if Stone[1] > 0 and Stone[0] < 7:
King[1] -= 1
Stone[1] -= 1
King[0] += 1
Stone[0] += 1
else:
King[1] -= 1
King[0] += 1
else:
return 0
print(Alphabet[King[1]] + str(8 - King[0]))
print(Alphabet[Stone[1]] + str(8 - Stone[0]))
solution()
https://www.acmicpc.net/problem/1063
Leave a comment