結果
| 問題 | No.2064 Smallest Sequence on Grid |
| コンテスト | |
| ユーザー |
とりゐ
|
| 提出日時 | 2021-08-10 04:55:33 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
RE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 515 bytes |
| 記録 | |
| コンパイル時間 | 266 ms |
| コンパイル使用メモリ | 85,148 KB |
| 実行使用メモリ | 166,656 KB |
| 最終ジャッジ日時 | 2026-05-11 05:14:52 |
| 合計ジャッジ時間 | 14,122 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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='')
とりゐ