結果

問題 No.1473 おでぶなおばけさん
ユーザー dot_haraaidot_haraai
提出日時 2021-04-12 19:24:33
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 1,541 bytes
コンパイル時間 4,725 ms
コンパイル使用メモリ 87,424 KB
実行使用メモリ 16,640 KB
最終ジャッジ日時 2024-06-28 16:10:00
合計ジャッジ時間 12,235 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 158 ms
14,976 KB
testcase_03 WA -
testcase_04 AC 68 ms
9,088 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 146 ms
14,336 KB
testcase_08 WA -
testcase_09 AC 138 ms
14,336 KB
testcase_10 AC 86 ms
14,336 KB
testcase_11 WA -
testcase_12 AC 89 ms
16,640 KB
testcase_13 AC 55 ms
8,960 KB
testcase_14 AC 39 ms
6,912 KB
testcase_15 AC 75 ms
11,520 KB
testcase_16 AC 82 ms
12,672 KB
testcase_17 AC 7 ms
5,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 105 ms
13,312 KB
testcase_22 AC 103 ms
13,184 KB
testcase_23 AC 84 ms
11,520 KB
testcase_24 AC 83 ms
11,648 KB
testcase_25 AC 106 ms
12,928 KB
testcase_26 AC 110 ms
13,696 KB
testcase_27 AC 40 ms
6,784 KB
testcase_28 AC 129 ms
14,080 KB
testcase_29 AC 114 ms
12,288 KB
testcase_30 AC 145 ms
14,592 KB
testcase_31 AC 124 ms
14,592 KB
testcase_32 WA -
testcase_33 AC 121 ms
12,544 KB
testcase_34 AC 51 ms
7,808 KB
testcase_35 AC 64 ms
8,960 KB
testcase_36 AC 79 ms
10,496 KB
testcase_37 AC 81 ms
11,136 KB
testcase_38 AC 17 ms
5,376 KB
testcase_39 AC 81 ms
12,800 KB
testcase_40 AC 81 ms
12,928 KB
testcase_41 AC 65 ms
9,216 KB
testcase_42 AC 65 ms
8,832 KB
testcase_43 AC 85 ms
14,208 KB
testcase_44 AC 84 ms
14,208 KB
testcase_45 AC 83 ms
14,208 KB
testcase_46 AC 83 ms
11,008 KB
testcase_47 AC 103 ms
12,800 KB
testcase_48 AC 91 ms
12,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(2, 18) Warning: Use the new 'sugar' module instead; future is deprecated [Deprecated]
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'times' [UnusedImport]
/home/judge/data/code/Main.nim(2, 26) Warning: imported and not used: 'strformat' [UnusedImport]
/home/judge/data/code/Main.nim(2, 18) Warning: imported and not used: 'future' [UnusedImport]
/home/judge/data/code/Main.nim(2, 8) Warning: imported and not used: 'critbits' [UnusedImport]
/home/judge/data/code/Main.nim(1, 41) Warning: imported and not used: 'algorithm' [UnusedImport]
/home/judge/data/code/Main.nim(1, 52) Warning: imported and not used: 'tables' [UnusedImport]
/home/judge/data/code/Main.nim(1, 60) Warning: imported and not used: 'sets' [UnusedImport]
/home/judge/data/code/Main.nim(1, 66) Warning: imported and not used: 'lists' [UnusedImport]
/home/judge/data/code/Main.nim(1, 73) Warning: imported and not used: 'intsets' [UnusedImport]

ソースコード

diff #

import times, strutils, sequtils, math, algorithm, tables, sets, lists, intsets
import critbits, future, strformat, deques
template `max=`(x,y) = x = max(x,y)
template `min=`(x,y) = x = min(x,y)
template `mod=`(x,y) = x = x mod y
template scan2 = (scan(), scan())
template scan3 = (scan(), scan())
let read* = iterator: string {.closure.} =
    while true: (for s in stdin.readLine.split: yield s)
proc scan(): int = read().parseInt
proc scanf(): float = read().parseFloat
proc toInt(c:char): int =
    return int(c) - int('0')



proc solve()=
  var
    (n,m)=(scan(),scan())
    edges = newseqwith(n,newseq[int]())
    hv = newseqwith(n,newseq[int]())
    mx = 10^12
    maxw = newseqwith(n,0)
    touch = newseqwith(n,false)
    pastp = newseqwith(n,-1)
  for i in 0..<m:
    var
      (s,t,d)=(scan()-1,scan()-1,scan())
    edges[s].add(t)
    edges[t].add(s)
    hv[s].add(d)
    hv[t].add(d)

  var
    q = initDeque[(int,int)]()
  # 次の頂点、次の頂点を設定したときの重さ最大値
  maxw[0]=mx
  q.addLast((0,mx))
  touch[0]=true
  while q.len>0:
    var
      (p,w) = q.popFirst()
      pastmaxw = maxw[p]
    if maxw[p]>w:
      continue

    for idx in 0..<edges[p].len:
      var
        nxt = edges[p][idx]
        weight = hv[p][idx]
      if maxw[nxt]<min(pastmaxw,weight):
        maxw[nxt]=min(pastmaxw,weight)
        q.addLast((nxt,maxw[nxt]))
        pastp[nxt]=p
  #echo maxw
  #echo pastp
  var
    p = n-1
    c = 0

  while p!=0:
    p = pastp[p]
    c+=1
  echo maxw[n-1], " ", c


    

  
solve()
0