結果

問題 No.1473 おでぶなおばけさん
ユーザー dot_haraaidot_haraai
提出日時 2021-04-12 19:24:33
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 1,541 bytes
コンパイル時間 4,581 ms
コンパイル使用メモリ 75,896 KB
実行使用メモリ 26,088 KB
最終ジャッジ日時 2023-09-11 01:38:50
合計ジャッジ時間 14,403 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 202 ms
25,520 KB
testcase_03 WA -
testcase_04 AC 86 ms
15,284 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 181 ms
26,088 KB
testcase_08 WA -
testcase_09 AC 173 ms
26,076 KB
testcase_10 AC 86 ms
14,596 KB
testcase_11 WA -
testcase_12 AC 91 ms
16,904 KB
testcase_13 AC 51 ms
8,112 KB
testcase_14 AC 38 ms
6,508 KB
testcase_15 AC 72 ms
10,720 KB
testcase_16 AC 83 ms
13,080 KB
testcase_17 AC 7 ms
4,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 127 ms
15,512 KB
testcase_22 AC 135 ms
20,400 KB
testcase_23 AC 119 ms
20,160 KB
testcase_24 AC 114 ms
17,620 KB
testcase_25 AC 141 ms
19,268 KB
testcase_26 AC 146 ms
18,816 KB
testcase_27 AC 45 ms
7,608 KB
testcase_28 AC 175 ms
25,636 KB
testcase_29 AC 137 ms
14,324 KB
testcase_30 AC 178 ms
16,952 KB
testcase_31 AC 167 ms
25,348 KB
testcase_32 WA -
testcase_33 AC 153 ms
18,328 KB
testcase_34 AC 62 ms
11,028 KB
testcase_35 AC 71 ms
10,236 KB
testcase_36 AC 86 ms
12,216 KB
testcase_37 AC 111 ms
18,912 KB
testcase_38 AC 18 ms
5,252 KB
testcase_39 AC 83 ms
13,160 KB
testcase_40 AC 85 ms
13,112 KB
testcase_41 AC 72 ms
10,816 KB
testcase_42 AC 73 ms
11,808 KB
testcase_43 AC 95 ms
15,920 KB
testcase_44 AC 96 ms
15,900 KB
testcase_45 AC 97 ms
15,980 KB
testcase_46 AC 104 ms
16,344 KB
testcase_47 AC 126 ms
19,072 KB
testcase_48 AC 120 ms
18,968 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