Agorithm/백준 알고리즘
백준 알고리즘 20493번 세상은 하나의 손수건(python)
kimjinho1
2021. 3. 21. 13:18
728x90
반응형
단순 구현 문제이다.
import sys
input = sys.stdin.readline
N, T = map(int, input().split())
d = [(1, 0), (0, -1), (-1, 0), (0, 1)]
i = X = Y = 0
li = [0]
for _ in range(N):
time, s = input().split()
time = int(time)
t = time-li[-1]
li.append(time)
x, y = d[i][0], d[i][1]
X += t*x; Y += t*y
i += 1 if s == 'right' else -1
i = i%4
t = T-li[-1]
x, y = d[i][0], d[i][1]
X += t*x; Y += t*y
print(X, Y)
728x90
반응형