Submission #352126
Source Code Expand
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.IO; class Myon { public Myon() { } public static int Main() { new Myon().calc(); return 0; } Scanner cin; void calc() { cin = new Scanner(); int N = cin.nextInt(); int M = cin.nextInt(); int[] A = new int[M]; int[] B = new int[M]; int[] C = new int[M]; for (int i = 0; i < M; i++) { A[i] = cin.nextInt() - 1; B[i] = cin.nextInt() - 1; C[i] = cin.nextInt(); } int K = cin.nextInt(); int MAX = int.MaxValue / 3; int[] dist = new int[N * 1025]; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { dist[(i << 10) + j] = MAX; } dist[(i<<10) + i] = 0; } for (int i = 0; i < M; i++) { dist[(A[i]<<10) + B[i]] = Math.Min(dist[(A[i] << 10) + B[i]], C[i]); dist[(B[i]<<10) + A[i]] = dist[(A[i] << 10) + B[i]]; } for (int k = 0; k < N; k++) { for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { dist[(i<<10) + j] = Math.Min(dist[(i<<10) + j], dist[(i<<10)+ k] + dist[(k<<10) + j]); } } } for (int t = 0; t < K; t++) { int x = cin.nextInt()-1; int y = cin.nextInt()-1; int z = cin.nextInt(); dist[(x<<10)+ y] = Math.Min(dist[(x<<10)+ y], z); dist[(y<<10)+ x] = dist[(x<<10)+ y]; for (int i = 0; i < N; i++) { for (int j = 0; j < i; j++) { dist[(i<<10)+ j] = Math.Min(dist[(i<<10)+ j] ,Math.Min(dist[(i<<10)+ x] + dist[(y<<10)+ j]+ z , dist[(i<<10)+ y] + dist[(x<<10)+ j] + z)); } } long ret = 0; for (int i = 0; i < N; i++) { for (int j = 0; j < i; j++) { dist[(j<<10)+ i] = dist[(i<<10)+ j]; ret += dist[(i<<10)+ j]; } } Console.WriteLine(ret); } } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); i = 0; return s[i++]; } public int nextInt() { return int.Parse(next()); } public long nextLong() { return long.Parse(next()); } public double nextDouble() { return double.Parse(next()); } } class XRand { uint x, y, z, w; public XRand() { init(); } public XRand(uint s) { init(); init_xor128(s); } void init() { x = 314159265; y = 358979323; z = 846264338; w = 327950288; } public void init_xor128(uint s) { z ^= s; z ^= z >> 21; z ^= z << 35; z ^= z >> 4; z *= 736338717; } uint next() { uint t = x ^ x << 11; x = y; y = z; z = w; return w = w ^ w >> 19 ^ t ^ t >> 8; } public long nextLong(long m) { return (long)((((ulong)next() << 32) + next()) % (ulong)m); } public int nextInt(int m) { return (int)(next() % m); } public long nextLong(long min, long max) { return min + nextLong(max - min + 1); } public int nextInt(int min, int max) { return min + nextInt(max - min + 1); } public int nextIntP(int a) { return (int)Math.Pow(a, nextDouble()); } public int nextIntP(int min, int max) { int diff = max - min; return min + nextIntP(diff + 2) - 1; } public long nextLongP(long a) { return (long)Math.Pow(a, nextDouble()); } public long nextLongP(long min, long max) { long diff = max - min; return min + nextLongP(diff + 2) - 1; } public double nextDouble() { return (double)next() / uint.MaxValue; } public double nextDoubleP(double a) { return Math.Pow(a, nextDouble()); } }
Submission Info
Submission Time | |
---|---|
Task | C - アットコーダー王国の交通事情 |
User | chokudai |
Language | C# (Mono 3.2.1.0) |
Score | 100 |
Code Size | 4875 Byte |
Status | AC |
Exec Time | 1885 ms |
Memory | 10572 KB |
Judge Result
Set Name | Sample | Subtask1 | All | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 10 / 10 | 90 / 90 | ||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
Sample | subtask0_sample_01.txt, subtask0_sample_02.txt |
Subtask1 | subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt, subtask1_21.txt, subtask1_22.txt, subtask1_23.txt, subtask1_24.txt, subtask1_25.txt, subtask1_26.txt, subtask1_27.txt, subtask1_28.txt, subtask1_29.txt |
All | subtask0_sample_01.txt, subtask0_sample_02.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt, subtask1_21.txt, subtask1_22.txt, subtask1_23.txt, subtask1_24.txt, subtask1_25.txt, subtask1_26.txt, subtask1_27.txt, subtask1_28.txt, subtask1_29.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
subtask0_sample_01.txt | AC | 163 ms | 8848 KB |
subtask0_sample_02.txt | AC | 162 ms | 8808 KB |
subtask1_01.txt | AC | 180 ms | 8892 KB |
subtask1_02.txt | AC | 1784 ms | 10312 KB |
subtask1_03.txt | AC | 1804 ms | 10320 KB |
subtask1_04.txt | AC | 1884 ms | 10564 KB |
subtask1_05.txt | AC | 1842 ms | 10560 KB |
subtask1_06.txt | AC | 1803 ms | 10572 KB |
subtask1_07.txt | AC | 1885 ms | 10560 KB |
subtask1_08.txt | AC | 1817 ms | 10548 KB |
subtask1_09.txt | AC | 1809 ms | 10552 KB |
subtask1_10.txt | AC | 1771 ms | 10560 KB |
subtask1_11.txt | AC | 1787 ms | 10484 KB |
subtask1_12.txt | AC | 1769 ms | 10560 KB |
subtask1_13.txt | AC | 1769 ms | 10560 KB |
subtask1_14.txt | AC | 1799 ms | 10548 KB |
subtask1_15.txt | AC | 1799 ms | 10560 KB |
subtask1_16.txt | AC | 1772 ms | 10520 KB |
subtask1_17.txt | AC | 1803 ms | 10504 KB |
subtask1_18.txt | AC | 1783 ms | 10556 KB |
subtask1_19.txt | AC | 1877 ms | 10544 KB |
subtask1_20.txt | AC | 1808 ms | 10568 KB |
subtask1_21.txt | AC | 1847 ms | 10496 KB |
subtask1_22.txt | AC | 1792 ms | 10552 KB |
subtask1_23.txt | AC | 1784 ms | 10556 KB |
subtask1_24.txt | AC | 181 ms | 9088 KB |
subtask1_25.txt | AC | 177 ms | 9068 KB |
subtask1_26.txt | AC | 181 ms | 9076 KB |
subtask1_27.txt | AC | 175 ms | 9080 KB |
subtask1_28.txt | AC | 178 ms | 9080 KB |
subtask1_29.txt | AC | 166 ms | 8968 KB |