Official
C - 矢印の道案内 / Arrow Navigation Editorial
by
C - 矢印の道案内 / Arrow Navigation Editorial
by
sounansya
Editorial for printing
高橋君をマスに従って順番に動かすシミュレーションを行えば良いです。
停止する条件の場合分けが少し面倒ですが、移動先がグリッドの外である場合も動くことにしてグリッドの外に出た場合に停止して答えを調整するようにすると実装が幾分か楽になります。
h, w = map(int, input().split())
s = [input() for _ in range(h)]
i = j = 0
while i < h and j < w:
if s[i][j] == '>':
j += 1
else:
i += 1
if i == h:
print(i, j + 1)
else:
print(i + 1, j)
posted:
last update:
