結果
問題 | No.1254 補強への架け橋 |
ユーザー | 箱星 |
提出日時 | 2020-10-09 22:31:57 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 340 ms / 2,000 ms |
コード長 | 3,234 bytes |
コンパイル時間 | 3,076 ms |
コンパイル使用メモリ | 108,416 KB |
実行使用メモリ | 74,932 KB |
最終ジャッジ日時 | 2024-07-20 12:54:39 |
合計ジャッジ時間 | 21,506 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 33 ms
21,248 KB |
testcase_01 | AC | 33 ms
21,120 KB |
testcase_02 | AC | 35 ms
21,376 KB |
testcase_03 | AC | 34 ms
21,120 KB |
testcase_04 | AC | 35 ms
21,376 KB |
testcase_05 | AC | 34 ms
20,992 KB |
testcase_06 | AC | 33 ms
21,376 KB |
testcase_07 | AC | 35 ms
21,120 KB |
testcase_08 | AC | 33 ms
21,248 KB |
testcase_09 | AC | 34 ms
21,120 KB |
testcase_10 | AC | 34 ms
21,120 KB |
testcase_11 | AC | 38 ms
21,120 KB |
testcase_12 | AC | 36 ms
21,248 KB |
testcase_13 | AC | 34 ms
21,376 KB |
testcase_14 | AC | 35 ms
21,376 KB |
testcase_15 | AC | 33 ms
20,992 KB |
testcase_16 | AC | 35 ms
20,992 KB |
testcase_17 | AC | 35 ms
21,248 KB |
testcase_18 | AC | 34 ms
21,248 KB |
testcase_19 | AC | 36 ms
21,120 KB |
testcase_20 | AC | 34 ms
21,248 KB |
testcase_21 | AC | 35 ms
21,248 KB |
testcase_22 | AC | 34 ms
21,376 KB |
testcase_23 | AC | 36 ms
21,376 KB |
testcase_24 | AC | 35 ms
21,120 KB |
testcase_25 | AC | 37 ms
21,248 KB |
testcase_26 | AC | 34 ms
21,376 KB |
testcase_27 | AC | 33 ms
21,376 KB |
testcase_28 | AC | 34 ms
21,248 KB |
testcase_29 | AC | 34 ms
21,504 KB |
testcase_30 | AC | 33 ms
21,248 KB |
testcase_31 | AC | 35 ms
21,504 KB |
testcase_32 | AC | 33 ms
21,248 KB |
testcase_33 | AC | 34 ms
21,376 KB |
testcase_34 | AC | 34 ms
20,992 KB |
testcase_35 | AC | 35 ms
21,376 KB |
testcase_36 | AC | 35 ms
21,248 KB |
testcase_37 | AC | 33 ms
21,248 KB |
testcase_38 | AC | 34 ms
21,248 KB |
testcase_39 | AC | 34 ms
20,992 KB |
testcase_40 | AC | 33 ms
21,248 KB |
testcase_41 | AC | 33 ms
21,376 KB |
testcase_42 | AC | 32 ms
21,248 KB |
testcase_43 | AC | 34 ms
21,856 KB |
testcase_44 | AC | 35 ms
21,248 KB |
testcase_45 | AC | 34 ms
21,504 KB |
testcase_46 | AC | 39 ms
21,760 KB |
testcase_47 | AC | 35 ms
21,372 KB |
testcase_48 | AC | 36 ms
21,756 KB |
testcase_49 | AC | 34 ms
21,376 KB |
testcase_50 | AC | 35 ms
22,016 KB |
testcase_51 | AC | 36 ms
22,016 KB |
testcase_52 | AC | 36 ms
21,888 KB |
testcase_53 | AC | 35 ms
22,016 KB |
testcase_54 | AC | 35 ms
21,888 KB |
testcase_55 | AC | 38 ms
21,760 KB |
testcase_56 | AC | 37 ms
21,248 KB |
testcase_57 | AC | 38 ms
21,716 KB |
testcase_58 | AC | 35 ms
21,596 KB |
testcase_59 | AC | 35 ms
21,504 KB |
testcase_60 | AC | 36 ms
21,248 KB |
testcase_61 | AC | 39 ms
21,844 KB |
testcase_62 | AC | 36 ms
21,632 KB |
testcase_63 | AC | 59 ms
28,672 KB |
testcase_64 | AC | 41 ms
23,040 KB |
testcase_65 | AC | 53 ms
27,904 KB |
testcase_66 | AC | 53 ms
25,344 KB |
testcase_67 | AC | 40 ms
22,536 KB |
testcase_68 | AC | 47 ms
25,600 KB |
testcase_69 | AC | 54 ms
27,648 KB |
testcase_70 | AC | 43 ms
23,552 KB |
testcase_71 | AC | 39 ms
23,168 KB |
testcase_72 | AC | 54 ms
27,520 KB |
testcase_73 | AC | 41 ms
23,168 KB |
testcase_74 | AC | 53 ms
27,776 KB |
testcase_75 | AC | 47 ms
25,600 KB |
testcase_76 | AC | 37 ms
22,260 KB |
testcase_77 | AC | 46 ms
24,960 KB |
testcase_78 | AC | 57 ms
28,416 KB |
testcase_79 | AC | 56 ms
28,544 KB |
testcase_80 | AC | 54 ms
27,520 KB |
testcase_81 | AC | 56 ms
28,544 KB |
testcase_82 | AC | 54 ms
28,032 KB |
testcase_83 | AC | 312 ms
62,816 KB |
testcase_84 | AC | 314 ms
60,256 KB |
testcase_85 | AC | 187 ms
46,432 KB |
testcase_86 | AC | 274 ms
57,124 KB |
testcase_87 | AC | 293 ms
60,040 KB |
testcase_88 | AC | 70 ms
30,720 KB |
testcase_89 | AC | 314 ms
60,880 KB |
testcase_90 | AC | 210 ms
47,164 KB |
testcase_91 | AC | 169 ms
45,036 KB |
testcase_92 | AC | 103 ms
37,120 KB |
testcase_93 | AC | 241 ms
52,292 KB |
testcase_94 | AC | 224 ms
49,972 KB |
testcase_95 | AC | 222 ms
49,808 KB |
testcase_96 | AC | 296 ms
59,632 KB |
testcase_97 | AC | 149 ms
44,412 KB |
testcase_98 | AC | 311 ms
59,992 KB |
testcase_99 | AC | 193 ms
46,156 KB |
testcase_100 | AC | 340 ms
61,704 KB |
testcase_101 | AC | 96 ms
34,432 KB |
testcase_102 | AC | 63 ms
28,544 KB |
testcase_103 | AC | 102 ms
37,248 KB |
testcase_104 | AC | 123 ms
39,296 KB |
testcase_105 | AC | 243 ms
52,160 KB |
testcase_106 | AC | 156 ms
43,536 KB |
testcase_107 | AC | 310 ms
60,896 KB |
testcase_108 | AC | 305 ms
60,520 KB |
testcase_109 | AC | 235 ms
51,948 KB |
testcase_110 | AC | 220 ms
49,632 KB |
testcase_111 | AC | 243 ms
51,536 KB |
testcase_112 | AC | 119 ms
38,912 KB |
testcase_113 | AC | 223 ms
48,660 KB |
testcase_114 | AC | 157 ms
42,368 KB |
testcase_115 | AC | 74 ms
30,592 KB |
testcase_116 | AC | 175 ms
45,560 KB |
testcase_117 | AC | 123 ms
39,936 KB |
testcase_118 | AC | 304 ms
59,460 KB |
testcase_119 | AC | 197 ms
45,876 KB |
testcase_120 | AC | 296 ms
59,528 KB |
testcase_121 | AC | 105 ms
36,480 KB |
testcase_122 | AC | 168 ms
45,308 KB |
testcase_123 | AC | 33 ms
21,248 KB |
testcase_124 | AC | 332 ms
74,804 KB |
testcase_125 | AC | 326 ms
74,932 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Linq; using System.Collections.Generic; using System.Text; using System.Numerics; public class Solution { private IList<int>[] graph; private bool[] visited; private int[] visitedTimes; private int[] lowVisitedTimes; private IList<IList<int>> criticalConnections; private int time; public IList<IList<int>> CriticalConnections(int n, IList<IList<int>> connections) { graph = new IList<int>[n]; visited = new bool[n]; visitedTimes = new int[n]; lowVisitedTimes = new int[n]; criticalConnections = new List<IList<int>>(); time = 0; InitGraph(n, connections); DFS(0, -1); return criticalConnections; } private void DFS(int current, int parent) { visited[current] = true; visitedTimes[current] = lowVisitedTimes[current] = time++; foreach (var server in graph[current]) { if (server == parent) { continue; } if (!visited[server]) { DFS(server, current); if (visitedTimes[current] < lowVisitedTimes[server]) { criticalConnections.Add(new List<int>(2) { current, server }); } else if (visitedTimes[current] > lowVisitedTimes[server]) { lowVisitedTimes[current] = lowVisitedTimes[server]; } } else { lowVisitedTimes[current] = Math.Min(lowVisitedTimes[current], visitedTimes[server]); } } } private void InitGraph(int n, IList<IList<int>> connections) { for (int i = 0; i < n; i++) { graph[i] = new List<int>(); } foreach (var connection in connections) { var a = connection[0]; var b = connection[1]; graph[a].Add(b); graph[b].Add(a); } } } class MyClass { public static void Solve() { var N = int.Parse(Console.ReadLine()); var edges = new List<IList<int>>(); var dic = new Dictionary<(int, int), int>(); for (int i = 0; i < N; i++) { var data = Console.ReadLine().Split().Select(int.Parse).ToArray(); var A = data[0] - 1; var B = data[1] - 1; var edge = new List<int>(); edge.Add(A); edge.Add(B); edges.Add(edge); dic.Add((A, B), i + 1); dic.Add((B, A), i + 1); } var sol = new Solution(); var pri = sol.CriticalConnections(N, edges); var ans = Enumerable.Range(1, N).ToHashSet(); foreach (var item in pri) { var A = item[0]; var B = item[1]; ans.Remove(dic[(A, B)]); } Console.WriteLine(ans.Count()); Console.WriteLine(string.Join(" ", ans)); } public static void Main() { var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Solve(); Console.Out.Flush(); } }