結果

問題 No.2064 Smallest Sequence on Grid
ユーザー vwxyzvwxyz
提出日時 2022-09-22 01:14:27
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,072 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 86,736 KB
実行使用メモリ 156,020 KB
最終ジャッジ日時 2023-08-23 20:17:05
合計ジャッジ時間 30,015 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 251 ms
91,396 KB
testcase_01 AC 243 ms
91,408 KB
testcase_02 AC 246 ms
91,044 KB
testcase_03 AC 253 ms
91,300 KB
testcase_04 AC 248 ms
91,404 KB
testcase_05 AC 247 ms
91,140 KB
testcase_06 AC 254 ms
91,348 KB
testcase_07 AC 248 ms
90,884 KB
testcase_08 AC 252 ms
91,256 KB
testcase_09 AC 250 ms
91,360 KB
testcase_10 AC 246 ms
91,288 KB
testcase_11 AC 250 ms
91,588 KB
testcase_12 AC 254 ms
91,604 KB
testcase_13 AC 262 ms
94,132 KB
testcase_14 AC 272 ms
94,088 KB
testcase_15 AC 256 ms
94,364 KB
testcase_16 AC 261 ms
94,088 KB
testcase_17 AC 343 ms
104,888 KB
testcase_18 AC 338 ms
105,092 KB
testcase_19 AC 347 ms
105,164 KB
testcase_20 AC 2,282 ms
132,516 KB
testcase_21 AC 2,434 ms
136,412 KB
testcase_22 AC 1,684 ms
121,336 KB
testcase_23 AC 1,834 ms
131,020 KB
testcase_24 AC 1,769 ms
131,708 KB
testcase_25 AC 1,854 ms
131,888 KB
testcase_26 TLE -
testcase_27 TLE -
testcase_28 AC 340 ms
104,692 KB
testcase_29 AC 2,780 ms
140,764 KB
testcase_30 AC 359 ms
104,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
import copy
import decimal
import fractions
import heapq
import itertools
import math
import random
import sys
import time
from collections import Counter,deque,defaultdict
from functools import lru_cache,reduce
from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max
def _heappush_max(heap,item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappushpop_max(heap, item):
    if heap and item < heap[0]:
        item, heap[0] = heap[0], item
        heapq._siftup_max(heap, 0)
    return item
from math import gcd as GCD
read=sys.stdin.read
readline=sys.stdin.readline
readlines=sys.stdin.readlines
write=sys.stdout.write

H,W=map(int,readline().split())
S=[readline().rstrip() for h in range(H)]
ans_lst=[S[0][0]]
queue=[(0,0)]
for _ in range(H+W-2):
    s=min([S[h+1][w] for h,w in queue if h+1<H]+[S[h][w+1] for h,w in queue if w+1<W])
    ans_lst.append(s)
    queue=list({(h+1,w) for h,w in queue if h+1<H and S[h+1][w]==s}|{(h,w+1) for h,w in queue if w+1<W and S[h][w+1]==s})
print(*ans_lst,sep="")
0