結果

問題 No.2064 Smallest Sequence on Grid
ユーザー umyomyomyonumyomyomyon
提出日時 2022-09-20 20:05:43
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 666 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 87,168 KB
実行使用メモリ 85,448 KB
最終ジャッジ日時 2023-08-23 19:38:30
合計ジャッジ時間 5,697 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,136 KB
testcase_01 AC 75 ms
71,260 KB
testcase_02 AC 73 ms
71,184 KB
testcase_03 AC 77 ms
71,276 KB
testcase_04 AC 74 ms
70,936 KB
testcase_05 AC 74 ms
71,236 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

H, W = list(map(int, input().split()))
S = [input() for _ in range(H)]
T = ''
def pick_right(h, w):
  if w == W - 1:
    return None
  return S[h][w + 1]

def pick_below(h, w):
  if h == H - 1:
    return None
  return S[h + 1][w]

def move(h, w):
  right = pick_right(h, w)
  below = pick_below(h, w)
  if right is None and below is None:
    return None
  if right is None:
    return (h + 1, w)
  if below is None:
    return (h, w + 1)
  if right > below:
    return (h + 1, w)
  if right < below:
    return (h , w + 1)

flag = True
h, w = 0, 0
while(flag):
  T += S[h][w]
  p = move(h, w)
  if p is None:
    flag = False
    break
  h, w = p[0], p[1]
print(T)
0