結果

問題 No.2064 Smallest Sequence on Grid
ユーザー とりゐとりゐ
提出日時 2021-08-10 04:55:33
言語 PyPy3
(7.3.15)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 515 bytes
コンパイル時間 416 ms
コンパイル使用メモリ 86,836 KB
実行使用メモリ 164,236 KB
最終ジャッジ日時 2023-08-10 02:32:52
合計ジャッジ時間 22,183 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
71,604 KB
testcase_01 RE -
testcase_02 AC 92 ms
71,612 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 90 ms
71,216 KB
testcase_06 AC 92 ms
71,528 KB
testcase_07 AC 91 ms
71,616 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 476 ms
158,396 KB
testcase_18 AC 476 ms
157,916 KB
testcase_19 AC 466 ms
158,260 KB
testcase_20 AC 1,535 ms
162,496 KB
testcase_21 AC 1,623 ms
162,760 KB
testcase_22 AC 1,248 ms
160,912 KB
testcase_23 AC 1,165 ms
161,788 KB
testcase_24 AC 1,157 ms
162,412 KB
testcase_25 AC 1,158 ms
161,748 KB
testcase_26 AC 1,904 ms
164,028 KB
testcase_27 AC 1,884 ms
164,236 KB
testcase_28 AC 483 ms
158,016 KB
testcase_29 RE -
testcase_30 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
h,w=map(int,input().split())
s=[]
for i in range(h):
  s.append(input())
a=[[0]*w for i in range(h)]
a[0][0]=1
dxdy=[(0,1),(1,0)]
ans=[]
for i in range(h+w-1):
  d=defaultdict(list)
  t=set()
  for x in range(max(0,i-h+1),min(i+1,w)):
    y=i-x
    if a[x][y]==1:
      d[s[x][y]].append((x,y))
      t.add(s[x][y])
  t=sorted(list(t))
  u=t[0]
  ans.append(u)
  for x,y in d[u]:
    for dx,dy in dxdy:
      if 0<=x+dx<h and 0<=y+dy<w:
        a[x+dx][y+dy]=1
print(*ans,sep='')
0