結果

問題 No.2064 Smallest Sequence on Grid
ユーザー とりゐ
提出日時 2021-08-10 05:05:07
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 532 bytes
コンパイル時間 532 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 293,524 KB
最終ジャッジ日時 2024-11-16 01:31:09
合計ジャッジ時間 60,966 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2
other WA * 15 OLE * 14
権限があれば一括ダウンロードができます

ソースコード

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 y in range(max(0,i-h+1),min(i+1,w)):
    x=i-y
    print(i,x,y)
    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