結果
問題 | No.17 2つの地点に泊まりたい |
ユーザー | tak |
提出日時 | 2018-04-10 00:59:10 |
言語 | F# (F# 4.0) |
結果 |
AC
|
実行時間 | 322 ms / 5,000 ms |
コード長 | 1,326 bytes |
コンパイル時間 | 12,915 ms |
コンパイル使用メモリ | 199,560 KB |
実行使用メモリ | 36,016 KB |
最終ジャッジ日時 | 2024-04-23 04:33:36 |
合計ジャッジ時間 | 20,041 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 310 ms
35,332 KB |
testcase_01 | AC | 308 ms
35,208 KB |
testcase_02 | AC | 312 ms
35,104 KB |
testcase_03 | AC | 311 ms
35,676 KB |
testcase_04 | AC | 306 ms
35,468 KB |
testcase_05 | AC | 304 ms
35,988 KB |
testcase_06 | AC | 308 ms
35,880 KB |
testcase_07 | AC | 304 ms
35,572 KB |
testcase_08 | AC | 309 ms
35,880 KB |
testcase_09 | AC | 315 ms
35,876 KB |
testcase_10 | AC | 318 ms
35,820 KB |
testcase_11 | AC | 310 ms
36,016 KB |
testcase_12 | AC | 312 ms
35,212 KB |
testcase_13 | AC | 316 ms
35,200 KB |
testcase_14 | AC | 322 ms
35,340 KB |
testcase_15 | AC | 311 ms
35,332 KB |
testcase_16 | AC | 307 ms
35,196 KB |
testcase_17 | AC | 313 ms
35,564 KB |
testcase_18 | AC | 313 ms
35,884 KB |
testcase_19 | AC | 310 ms
35,484 KB |
testcase_20 | AC | 311 ms
35,548 KB |
testcase_21 | AC | 309 ms
35,228 KB |
testcase_22 | AC | 309 ms
35,656 KB |
testcase_23 | AC | 313 ms
35,796 KB |
testcase_24 | AC | 311 ms
35,852 KB |
testcase_25 | AC | 313 ms
35,100 KB |
testcase_26 | AC | 307 ms
35,952 KB |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (556 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
open System open System.Collections.Generic type WarshallFloyd(n,?isNonDir0:bool)= let isNonDir = defaultArg isNonDir0 true let inf = 1e16|>int64 let vertexNum = n let edgeNum = ref 0 let costs = Array2D.init<int64> (n+1) (n+1) (fun i j-> if i <> j then inf else 0L) member this.Inf = inf member this.AddPath f t c = incr edgeNum costs.[f,t]<-min costs.[f,t] c if isNonDir then costs.[t,f]<-min costs.[t,f] c member this.Run() = for i in 0..vertexNum do for j in 0..vertexNum do for k in 0..vertexNum do costs.[j,k]<-min costs.[j,k] (costs.[j,i]+costs.[i,k]) member this.PathExist f t = costs.[f,t] <> inf member this.MinCosts() = costs member this.MinCost f t = costs.[f,t] let read() = Console.ReadLine() let N = read() |> int let ws = WarshallFloyd(N) let S = Array.init N (fun _ -> read() |> int64) let M = read() |> int for i in 0..M-1 do let t = read().Split() ws.AddPath (t.[0] |> int) (t.[1] |> int) (t.[2] |> int64) ws.Run() [for i in [1..N-2] do for j in [1..N-2] do if i <> j then yield (i,j)] |> List.map (fun (a,b) -> (ws.MinCost 0 a) + S.[a] + (ws.MinCost a b) + S.[b] + (ws.MinCost b (N-1))) |> List.min |> printfn "%i"