結果
問題 | No.859 路線A、路線B、路線C |
ユーザー | bluemegane |
提出日時 | 2021-05-07 15:36:20 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,155 bytes |
コンパイル時間 | 4,322 ms |
コンパイル使用メモリ | 104,576 KB |
実行使用メモリ | 18,048 KB |
最終ジャッジ日時 | 2024-09-15 04:01:24 |
合計ジャッジ時間 | 3,507 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 24 ms
17,664 KB |
testcase_01 | AC | 25 ms
18,048 KB |
testcase_02 | AC | 24 ms
17,664 KB |
testcase_03 | AC | 25 ms
17,920 KB |
testcase_04 | AC | 25 ms
17,792 KB |
testcase_05 | AC | 24 ms
17,536 KB |
testcase_06 | AC | 25 ms
17,536 KB |
testcase_07 | AC | 24 ms
17,664 KB |
testcase_08 | AC | 25 ms
17,664 KB |
testcase_09 | WA | - |
testcase_10 | AC | 25 ms
17,920 KB |
testcase_11 | AC | 25 ms
17,792 KB |
testcase_12 | AC | 25 ms
17,792 KB |
testcase_13 | AC | 24 ms
17,664 KB |
testcase_14 | WA | - |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; public class Hello { static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var a = Array.ConvertAll(line, int.Parse); line = Console.ReadLine().Trim().Split(' '); var s0 = line[0]; var t0 = int.Parse(line[1]); line = Console.ReadLine().Trim().Split(' '); var s1 = line[0]; var t1 = int.Parse(line[1]); if (s0 == s1) { if (s0 == "A") Same(a, t0, t1, 0, 1, 2); else if (s0 == "B") Same(a, t0, t1, 1, 0, 2); else Same(a, t0, t1, 2, 0, 1); } else { if ((s0 == "A" && s1 == "B") | (s0 == "B" && s1 == "A")) Diff(a, t0, t1, 0, 1, 2); else if ((s0 == "B" && s1 == "C") | (s0 == "C" && s1 == "B")) Diff(a, t0, t1, 2, 1, 0); else Diff(a, t0, t1, 0, 2, 1); } } static void Diff(int[] a, int t0, int t1, int p, int q, int r) { var dp = new long[8, 8]; for (int i = 0; i < 8; i++) for (int j = 0; j < 8; j++) { if (i == j) dp[i, i] = 0; else dp[i, j] = int.MaxValue * 10L; } dp[4, 5] = a[r] - 1; dp[5, 4] = dp[4, 5]; dp[0, 2] = 1; dp[2, 0] = dp[0, 2]; dp[2, 4] = 1; dp[4, 2] = dp[2, 4]; dp[0, 4] = 1; dp[4, 0] = dp[0, 4]; dp[1, 3] = 1; dp[3, 1] = dp[1, 3]; dp[3, 5] = 1; dp[5, 3] = dp[3, 5]; dp[1, 5] = 1; dp[5, 1] = dp[1, 5]; dp[0, 6] = t0 - 1; dp[6, 0] = dp[0, 6]; dp[1, 6] = a[p] - t0; dp[6, 1] = dp[1, 6]; dp[2, 7] = t1 - 1; dp[7, 2] = dp[2, 7]; dp[3, 7] = a[q] - t1; dp[7, 3] = dp[3, 7]; goWarshall(dp); Console.WriteLine(dp[6, 7]); } static void Same(int[] a, int t0, int t1, int p, int q, int r) { if (t0 > t1) { Same(a, t1, t0, p, q, r); return; } var dp = new long[8, 8]; for (int i = 0; i < 8; i++) for (int j = 0; j < 8; j++) { if (i == j) dp[i, i] = 0; else dp[i, j] = int.MaxValue * 10L; } dp[2, 3] = a[q] - 1; dp[3, 2] = dp[2, 3]; dp[4, 5] = a[r] - 1; dp[5, 4] = dp[4, 5]; dp[0, 2] = 1; dp[2, 0] = dp[0, 2]; dp[2, 4] = 1; dp[4, 2] = dp[2, 4]; dp[0, 4] = 1; dp[4, 0] = dp[0, 4]; dp[1, 3] = 1; dp[3, 1] = dp[1, 3]; dp[3, 5] = 1; dp[5, 3] = dp[3, 5]; dp[1, 5] = 1; dp[5, 1] = dp[1, 5]; dp[0, 6] = t0 - 1; dp[6, 0] = dp[0, 6]; dp[6, 7] = t1 - t0; dp[7, 6] = dp[6, 7]; dp[7, 1] = a[p] - t1; dp[1, 7] = dp[7, 1]; goWarshall(dp); Console.WriteLine(dp[6, 7]); } static void goWarshall(long[,] dp) { var n = dp.GetLength(0); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) for (int k = 0; k < n; k++) dp[j, k] = Math.Min(dp[j, k], dp[j, i] + dp[i, k]); } }