結果
| 問題 |
No.2064 Smallest Sequence on Grid
|
| コンテスト | |
| ユーザー |
とりゐ
|
| 提出日時 | 2021-08-10 04:55:33 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 515 bytes |
| コンパイル時間 | 507 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 163,072 KB |
| 最終ジャッジ日時 | 2024-11-16 01:30:07 |
| 合計ジャッジ時間 | 20,925 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 RE * 1 |
| other | AC * 16 RE * 13 |
ソースコード
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='')
とりゐ