結果

問題 No.2064 Smallest Sequence on Grid
ユーザー vwxyzvwxyz
提出日時 2023-01-14 19:42:38
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,072 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 155,704 KB
最終ジャッジ日時 2023-08-27 00:51:00
合計ジャッジ時間 27,386 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 260 ms
91,728 KB
testcase_01 AC 259 ms
91,588 KB
testcase_02 AC 259 ms
91,456 KB
testcase_03 AC 260 ms
91,448 KB
testcase_04 AC 260 ms
91,560 KB
testcase_05 AC 258 ms
91,620 KB
testcase_06 AC 258 ms
91,372 KB
testcase_07 AC 253 ms
91,448 KB
testcase_08 AC 252 ms
91,768 KB
testcase_09 AC 255 ms
91,444 KB
testcase_10 AC 257 ms
91,688 KB
testcase_11 AC 261 ms
91,900 KB
testcase_12 AC 262 ms
91,708 KB
testcase_13 AC 272 ms
94,252 KB
testcase_14 AC 275 ms
94,548 KB
testcase_15 AC 273 ms
94,416 KB
testcase_16 AC 280 ms
94,664 KB
testcase_17 AC 359 ms
105,424 KB
testcase_18 AC 357 ms
105,176 KB
testcase_19 AC 353 ms
105,416 KB
testcase_20 AC 2,351 ms
132,688 KB
testcase_21 AC 2,576 ms
136,824 KB
testcase_22 AC 1,736 ms
121,484 KB
testcase_23 AC 1,872 ms
130,952 KB
testcase_24 AC 1,861 ms
132,136 KB
testcase_25 AC 1,869 ms
131,772 KB
testcase_26 TLE -
testcase_27 TLE -
testcase_28 AC 387 ms
105,396 KB
testcase_29 AC 2,894 ms
141,212 KB
testcase_30 AC 381 ms
104,576 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