結果
問題 | No.1449 新プロランド |
ユーザー | tatt61880 |
提出日時 | 2021-04-09 08:20:58 |
言語 | Kuin (KuinC++ v.2021.9.17) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 6,116 bytes |
コンパイル時間 | 3,934 ms |
コンパイル使用メモリ | 150,072 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-06 11:08:42 |
合計ジャッジ時間 | 5,027 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 11 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 3 ms
5,376 KB |
testcase_05 | AC | 107 ms
5,504 KB |
testcase_06 | AC | 70 ms
5,376 KB |
testcase_07 | AC | 30 ms
5,376 KB |
testcase_08 | AC | 65 ms
5,376 KB |
testcase_09 | AC | 46 ms
5,376 KB |
testcase_10 | AC | 30 ms
5,376 KB |
testcase_11 | AC | 11 ms
5,376 KB |
testcase_12 | AC | 58 ms
5,376 KB |
testcase_13 | AC | 45 ms
5,376 KB |
testcase_14 | AC | 8 ms
5,376 KB |
testcase_15 | AC | 72 ms
5,376 KB |
testcase_16 | AC | 41 ms
5,376 KB |
testcase_17 | AC | 49 ms
5,376 KB |
testcase_18 | AC | 2 ms
5,376 KB |
testcase_19 | AC | 3 ms
5,376 KB |
testcase_20 | AC | 2 ms
5,376 KB |
testcase_21 | AC | 15 ms
5,376 KB |
testcase_22 | AC | 8 ms
5,376 KB |
testcase_23 | AC | 25 ms
5,376 KB |
testcase_24 | AC | 36 ms
5,376 KB |
testcase_25 | WA | - |
testcase_26 | AC | 2 ms
5,376 KB |
testcase_27 | AC | 128 ms
5,504 KB |
testcase_28 | AC | 66 ms
5,376 KB |
ソースコード
func main() var n: int :: cui@inputInt() var m: int :: cui@inputInt() var a: []int :: #[m]int var b: []int :: #[m]int var c: []int :: #[m]int for i(0, m - 1) do a[i] :: cui@inputInt() - 1 do b[i] :: cui@inputInt() - 1 do c[i] :: cui@inputInt() end for var t: []int :: #[n]int for i(0, n - 1) do t[i] :: cui@inputInt() end for var cc: [][]int :: #[n, n]int var neighbor: [][]int :: #[n, 0]int for i(0, m - 1) do neighbor[a[i]] :~ [b[i]] do neighbor[b[i]] :~ [a[i]] do cc[a[i]][b[i]] :: c[i] do cc[b[i]][a[i]] :: c[i] end for var maxCplus1: int :: c.max() + 1 var used: []bool :: #[maxCplus1 * n + n]bool var minTime: []int :: [lib@intMax].repeat((n - 1) * (maxCplus1 + 1) + maxCplus1 + 1) do minTime[0] :: 0 var q: @Set :: #@Set do q.add(0) while loop(q.size() <> 0) var uVal: int :: q.begin().key do q.del(uVal) var u: int :: uVal % 10 ^ 6 if(used[u]) skip loop end if do used[u] :: true var posU: int :: u / (maxCplus1 + 1) var pUt: int :: u % (maxCplus1 + 1) + t[posU] for i(0, ^neighbor[posU] - 1) var posV: int :: neighbor[posU][i] var pV: int :: [pUt, maxCplus1].min() var v: int :: posV * (maxCplus1 + 1) + pV var time: int :: minTime[u] + cc[posU][posV] / pUt + t[posU] if(time < minTime[v]) do minTime[v] :: time var vVal: int :: time * 10 ^ 6 + v do q.add(vVal) end if end for end while var ans: int :: minTime.sub((n - 1) * maxCplus1, -1).min() do cui@print("\{ans}\n") end func class Node() +var height: int +var key: int +var prev: Node +var next: Node +var lst: Node +var rst: Node +*func toStr(): []char ret me.key.toStr() end func +func init(key: int, prev: Node, next: Node): Node do me.height :: 1 do me.key :: key do me.prev :: prev do me.next :: next ret me end func end class ; AVL Tree class Set() var root: @Node var change: bool var lMax: int var num: int +*func toStr(): []char ret me.toGraph(me.root, "", "") end func func toGraph(t: @Node, head: []char, bar: []char): []char var res: []char :: "" if(t <>& null) do res :~ me.toGraph(t.rst, head ~ " ", "/") do res :~ head ~ bar ~ t.key.toStr() ~ "\n" do res :~ me.toGraph(t.lst, head ~ " ", "`") end if ret res end func +func size(): int ret me.num end func +func begin(): @Node var t: @Node :: me.root if(t =& null) ret null end if while(true) if(t.lst =& null) ret t end if do t :: t.lst end while end func +func add(key: int) do me.root :: me.addSub(me.root, null, key) end func func addSub(t: @Node, parent: @Node, key: int): @Node if(t =& null) var a: @Node do me.change :: true if(parent =& null) do a :: (#@Node).init(key, null, null) elif(key < parent.key) do a :: (#@Node).init(key, parent.prev, parent) if(parent.prev <>& null) do parent.prev.next :: a end if do parent.prev :: a elif(key > parent.key) do a :: (#@Node).init(key, parent, parent.next) if(parent.next <>& null) do parent.next.prev :: a end if do parent.next :: a end if do me.num :+ 1 ret a elif(key < t.key) do t.lst :: me.addSub(t.lst, t, key) ret me.balanceL(t) elif(key > t.key) do t.rst :: me.addSub(t.rst, t, key) ret me.balanceR(t) else do me.change :: false ret t end if end func +func del(key: int) do me.root :: me.delSub(me.root, key) end func func delSub(t: @Node, key: int): @Node if(t =& null) do me.change :: false ret null elif(key < t.key) do t.lst :: me.delSub(t.lst, key) ret me.balanceR(t) elif(key > t.key) do t.rst :: me.delSub(t.rst, key) ret me.balanceL(t) else do me.num :- 1 if(t.next <>& null) do t.next.prev :: t.prev end if if(t.prev <>& null) do t.prev.next :: t.next end if if(t.lst =& null) do me.change :: true ret t.rst else do t.lst :: me.delSubMax(t.lst) do t.key :: me.lMax ret me.balanceR(t) end if end if end func func delSubMax(t: @Node): @Node if(t.rst <>& null) do t.rst :: me.delSubMax(t.rst) ret me.balanceL(t) else do me.change :: true do me.lMax :: t.key ret t.lst end if end func +func find(key: int): @Node var t: @Node :: me.root while loop(t <>& null) if(key < t.key) do t :: t.lst elif(key > t.key) do t :: t.rst else break loop end if end while ret t end func +func exist(key: int): bool ret me.find(key) <>& null end func +func lower_bound(key: int): @Node var t: @Node :: me.root if(t =& null) ret null end if while(true) if(key < t.key) if(t.lst =& null) ret t end if do t :: t.lst elif(key > t.key) if(t.rst =& null) ret t.next end if do t :: t.rst else ret t end if end while end func func height(t: @Node): int ret t =& null ?(0, t.height) end func func bias(t: @Node): int ret me.height(t.lst) - me.height(t.rst) end func func modHeight(t: @Node) do t.height :: 1 + lib@max(me.height(t.lst), me.height(t.rst)) end func func rotateL(v: @Node): @Node var u: @Node :: v.rst var t: @Node :: u.lst do u.lst :: v do v.rst :: t ret u end func func rotateR(u: @Node): @Node var v: @Node :: u.lst var t: @Node :: v.rst do v.rst :: u do u.lst :: t ret v end func func rotateLR(t: @Node): @Node do t.lst :: me.rotateL(t.lst) ret me.rotateR(t) end func func rotateRL(t: @Node): @Node do t.rst :: me.rotateR(t.rst) ret me.rotateL(t) end func func balanceL(t: @Node): @Node if(!me.change) ret t end if var h: int :: me.height(t) if(me.bias(t) = 2) if(me.bias(t.lst) >= 0) do t :: me.rotateR(t) else do t :: me.rotateLR(t) end if else do me.modHeight(t) end if do me.change :: h <> me.height(t) ret t end func func balanceR(t: @Node): @Node if(!me.change) ret t end if var h: int :: me.height(t) if(me.bias(t) = -2) if(me.bias(t.rst) <= 0) do t :: me.rotateL(t) else do t :: me.rotateRL(t) end if else do me.modHeight(t) end if do me.change :: h <> me.height(t) ret t end func end class