結果

問題 No.2064 Smallest Sequence on Grid
ユーザー とりゐとりゐ
提出日時 2022-08-27 12:09:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 770 ms / 3,000 ms
コード長 478 bytes
コンパイル時間 428 ms
コンパイル使用メモリ 81,972 KB
実行使用メモリ 99,568 KB
最終ジャッジ日時 2024-04-27 20:16:07
合計ジャッジ時間 9,033 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
52,292 KB
testcase_01 AC 32 ms
52,556 KB
testcase_02 AC 30 ms
53,344 KB
testcase_03 AC 32 ms
52,080 KB
testcase_04 AC 33 ms
53,232 KB
testcase_05 AC 31 ms
52,024 KB
testcase_06 AC 30 ms
53,372 KB
testcase_07 AC 30 ms
53,820 KB
testcase_08 AC 37 ms
58,896 KB
testcase_09 AC 34 ms
58,196 KB
testcase_10 AC 39 ms
60,360 KB
testcase_11 AC 41 ms
62,056 KB
testcase_12 AC 43 ms
62,584 KB
testcase_13 AC 45 ms
64,704 KB
testcase_14 AC 43 ms
63,816 KB
testcase_15 AC 45 ms
64,304 KB
testcase_16 AC 45 ms
65,072 KB
testcase_17 AC 166 ms
86,380 KB
testcase_18 AC 170 ms
86,400 KB
testcase_19 AC 166 ms
86,484 KB
testcase_20 AC 597 ms
93,700 KB
testcase_21 AC 643 ms
94,972 KB
testcase_22 AC 475 ms
90,640 KB
testcase_23 AC 478 ms
93,152 KB
testcase_24 AC 478 ms
92,836 KB
testcase_25 AC 484 ms
92,824 KB
testcase_26 AC 767 ms
99,472 KB
testcase_27 AC 770 ms
99,568 KB
testcase_28 AC 169 ms
86,456 KB
testcase_29 AC 658 ms
94,856 KB
testcase_30 AC 163 ms
85,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

h,w=map(int,input().split())
s=[]
for i in range(h):
  s.append(input())
dxdy=[(0,1),(1,0)]
ans=[]
todo=[(0,0)]
for i in range(h+w-1):
  d=[]
  mn='z'
  for x,y in todo:
    if mn==s[x][y]:
      d.append((x,y))
    elif mn>s[x][y]:
      d=[(x,y)]
      mn=s[x][y]
  ans.append(mn)
  todo=[]
  ok=[0]*h
  for x,y in d:
    for dx,dy in dxdy:
      if 0<=x+dx<h and 0<=y+dy<w:
        ok[x+dx]=1
  for x in range(h):
    if ok[x]:
      todo.append((x,i+1-x))
print(*ans,sep='')
0