結果

問題 No.2855 Move on Grid
ユーザー E49869826E49869826
提出日時 2024-08-25 14:12:31
言語 Nim
(2.0.2)
結果
AC  
実行時間 702 ms / 3,000 ms
コード長 7,464 bytes
コンパイル時間 4,487 ms
コンパイル使用メモリ 103,244 KB
実行使用メモリ 29,528 KB
最終ジャッジ日時 2024-08-25 14:13:00
合計ジャッジ時間 26,927 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
8,192 KB
testcase_01 AC 185 ms
10,240 KB
testcase_02 AC 123 ms
8,064 KB
testcase_03 AC 82 ms
6,940 KB
testcase_04 AC 54 ms
6,940 KB
testcase_05 AC 123 ms
8,576 KB
testcase_06 AC 134 ms
8,192 KB
testcase_07 AC 14 ms
6,940 KB
testcase_08 AC 103 ms
7,680 KB
testcase_09 AC 53 ms
6,940 KB
testcase_10 AC 664 ms
29,268 KB
testcase_11 AC 632 ms
29,528 KB
testcase_12 AC 634 ms
29,320 KB
testcase_13 AC 657 ms
29,216 KB
testcase_14 AC 650 ms
29,328 KB
testcase_15 AC 622 ms
29,344 KB
testcase_16 AC 659 ms
29,216 KB
testcase_17 AC 629 ms
29,328 KB
testcase_18 AC 639 ms
29,312 KB
testcase_19 AC 611 ms
29,348 KB
testcase_20 AC 604 ms
29,264 KB
testcase_21 AC 661 ms
29,264 KB
testcase_22 AC 624 ms
29,220 KB
testcase_23 AC 663 ms
29,344 KB
testcase_24 AC 667 ms
29,232 KB
testcase_25 AC 698 ms
27,972 KB
testcase_26 AC 673 ms
29,268 KB
testcase_27 AC 664 ms
29,272 KB
testcase_28 AC 651 ms
29,272 KB
testcase_29 AC 682 ms
29,268 KB
testcase_30 AC 677 ms
27,232 KB
testcase_31 AC 678 ms
27,344 KB
testcase_32 AC 688 ms
27,604 KB
testcase_33 AC 651 ms
26,232 KB
testcase_34 AC 667 ms
26,228 KB
testcase_35 AC 702 ms
27,044 KB
testcase_36 AC 668 ms
26,816 KB
testcase_37 AC 695 ms
26,228 KB
testcase_38 AC 694 ms
27,220 KB
testcase_39 AC 659 ms
26,484 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
check is on
optimized for speed

ソースコード

diff #

# Please use Nim-ACL
import macros; macro ImportExpand(s:untyped):untyped = parseStmt(staticExec("echo " & $s[2] & " | base64 -d | xzcat"))
# const OPTIMIZE_SIZE = true
ImportExpand "e_lib/templates/prelude.nim" <=== "/Td6WFoAAATm1rRGAgAhARwAAAAQz1jM4AG2AM1dADuaCNQtYnSg9EGWFdHzgJ4ZEZPA2A4GC71uJBE1Q5DCmJ6ip+BHSeOQAxKLZNxc8uvrgoLZaEvkfszH6ztT7Cqw+jwCLVNdnRZ/o9+gCa9AuZUCsQ4v1tT4NKMRrzE/FkvGFODweh31CM40Dbck8Q+4kjr0K6GP8du1rARBMqUymwor117W4ZKywO7//4q3Bv0h2J6NQM80thqxqFGl8ClE2WagETBiKou1DlpVvHO5fv1Mjn1l8RNWhRCFV2rSKTSfdGoS/coONb2/AAAAAAAAUjvPkh7B5A8AAekBtwMAAF1/nU2xxGf7AgAAAAAEWVo="
ImportExpand "e_lib/templates/header.nim" <=== "/Td6WFoAAATm1rRGAgAhARwAAAAQz1jM4A03BGddADuaCNQtYnSg9EGWFdHzgJ4ZEZPA2A4GC71uJBE1Q5DCmJ6f3yWtfXn3fnQS4aijNu6l8Uo6ftl2FqcVWTxulBCVzbwZmthVa2BR2tn5B3n37+4XoWtM6D4AWOTIY8fndEh4DTiI1d2bb0AbFoKIPUEfsGCKt5Se4b5iay5XXGPOLEvuX61pve/ppfJWzxIbD/xRoA9dt5J5QgyvmlAsRX7wcLGoYj8cEf8MJI2oGJ0lPhBOcbjlVWQaeq1WS7Qi1SfKV7Q1dxhbVJnkD3mzqjz75Xi6H+AL4JttO40lrn+P3N+HAVxBe+tuL61ohP2l2nlI1aCt4onIeKVet7HCeEOFqHq6plGJdwWahzJcva3UmaY3L+i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GdveWfgtHG2fy4ho0IPt9cSwiC2FhwFVqD4rc0mzXCSypw90fONMkXZe/8eUAABFDYk4U9GKwgABgwm4GgAACZAWn7HEZ/sCAAAAAARZWg=="
ImportExpand "atcoder/extra/other/binary_search.nim" <=== "/Td6WFoAAATm1rRGAgAhARwAAAAQz1jM4AI3APpdADuaCNQtYnSg9EGWFdHzgJ4ZEZO9/uQdsAvy/1hn00IqXh+n5DDuV5mTHPGnhN3FXImtHlqdMsBEtUx9K9Ryd0UXfMLCEkkKrhzBhJWIyAb705Wv6tJCwtinOOD+7aSfFChH4SwxVflfm/zgKLGilqS4lK69cH6G5nl/eSwDEpxCP3gW85PYMoOVUhAO+wezNcEqFxSiJzYTp4QAY0F0pW7GfrgvetQOtC1T4N2wEKuO9LGTVOy61j7QHilda+50t6rKESww8yyUA7w6FfkfjbgJ4wMesh2vx2NEV1qvf1NHc/fr5NyUIwjsSoL5mSpEKvUELXV8+lEGAAAAAADyNr4uAX4ZhwABlgK4BAAASrxlrbHEZ/sCAAAAAARZWg=="
ImportExpand "atcoder/extra/graph/graph_template.nim" <=== "/Td6WFoAAATm1rRGAgAhARwAAAAQz1jM4BdqBeRdADuaCNQtYnSg9EGWFdHzgJ4ZEZO9/uQdsAvy/1jPWpAImh8oU/eOEKQFjASRBr2kUJXmQkkU3UIlj8A5bYgT6Lr0KqysLgVFqoZILNTGcgSiuFSFGRXnUM04CodJ+FlO5a08mNGX9Uk1Dk87eQFHmaY3NmvEIfQhWbeQs9elYYrOLmMRWK/NF2y9bZ+4hy6sSN7BomDHxuKbKWo6L45Lwc+AfPKYKTgtMrhBJHU77tGAtaWywiJ07M+Bxvh/EsYWf42MeYtMafF0kbGHq1XzvE1exWuL1uad07QL/oJeCuPi9Bs576ZmJ+sr9gxnnuKOsXpUNe1sovfRnHBB4Os2djd/5WQis22mNcD+TRrCRRwZdjO/bdLW+x3r09BNBgSdrsQ1ICAp6iKDQpSu2GDmLiqiCQi5nV7g9aK5BndQY+DDS1tjDtS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rFg3qqbb/UkoJ47qMWkkJJscE6VryEnQ3aBMMV/MtLlzB0yxKGktFL3UaTOYptfr7xdPpwtduEt6mIslH6SjWRlBu8/RbfjhbWg3Oa55LWt0/KKpLkCF207tdDjYfZmpPfE53+HBq/mclzbdqcHUG7FG/imI15s8FJYgB9yUeTr5FrjvlJ15GXdkcvDnMD4nRf5KkEqOTKMbMcvWQmwIbdA0vAAAAAAA7RGeV4IWm3wABtQr5JAAAq/nIB7HEZ/sCAAAAAARZWg=="

const moves = [[-1,0],[0,-1],[0,1],[1,0]]

proc solve(N,M,K:int;A:seq[seq[int]]):void =
  proc f(i,j:int):int = return i*M+j
  proc f(v:int):bool =
    var g = initGraph(N*M)
    for i in 0..<N:
      for j in 0..<M:
        let te2 = f(i,j)
        for k in moves:
          let te1 = [i+k[0],j+k[1]]
          if te1[0] in 0..<N and te1[1] in 0..<M:
            g.addEdge(f(te1[0],te1[1]),te2,(if A[i][j] >= v: 0 else: 1))
    var d = dijkstra01(g,0)
    return d[N*M-1]+(if A[0][0] >= v: 0 else: 1) <= K
  echo maxRight(f,0..10^9)
  return

proc main():void =
  # Failed to predict input format
  let N, M, K = nextInt()
  let A = newSeqWith(N,newSeqWith(M,nextInt()))
  solve(N,M,K,A)
  return

main()
0