結果
問題 | No.1254 補強への架け橋 |
ユーザー | marroncastle |
提出日時 | 2020-10-10 01:44:48 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,991 bytes |
コンパイル時間 | 313 ms |
コンパイル使用メモリ | 82,052 KB |
実行使用メモリ | 135,860 KB |
最終ジャッジ日時 | 2024-07-20 15:22:43 |
合計ジャッジ時間 | 28,617 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 50 ms
66,176 KB |
testcase_01 | AC | 49 ms
60,160 KB |
testcase_02 | AC | 49 ms
60,160 KB |
testcase_03 | AC | 49 ms
60,672 KB |
testcase_04 | AC | 49 ms
60,672 KB |
testcase_05 | AC | 48 ms
60,288 KB |
testcase_06 | AC | 49 ms
60,032 KB |
testcase_07 | AC | 47 ms
60,672 KB |
testcase_08 | AC | 48 ms
60,672 KB |
testcase_09 | AC | 49 ms
60,672 KB |
testcase_10 | AC | 49 ms
60,544 KB |
testcase_11 | AC | 50 ms
60,160 KB |
testcase_12 | AC | 49 ms
60,928 KB |
testcase_13 | AC | 50 ms
60,288 KB |
testcase_14 | AC | 49 ms
60,928 KB |
testcase_15 | AC | 48 ms
60,800 KB |
testcase_16 | AC | 48 ms
60,288 KB |
testcase_17 | AC | 49 ms
60,672 KB |
testcase_18 | AC | 48 ms
60,288 KB |
testcase_19 | AC | 49 ms
60,160 KB |
testcase_20 | AC | 51 ms
60,672 KB |
testcase_21 | AC | 51 ms
60,288 KB |
testcase_22 | AC | 51 ms
60,800 KB |
testcase_23 | AC | 49 ms
60,544 KB |
testcase_24 | AC | 49 ms
60,416 KB |
testcase_25 | AC | 48 ms
60,800 KB |
testcase_26 | WA | - |
testcase_27 | AC | 48 ms
60,416 KB |
testcase_28 | AC | 51 ms
60,544 KB |
testcase_29 | AC | 52 ms
60,800 KB |
testcase_30 | AC | 52 ms
60,160 KB |
testcase_31 | AC | 49 ms
60,800 KB |
testcase_32 | AC | 48 ms
60,416 KB |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | AC | 51 ms
60,928 KB |
testcase_36 | WA | - |
testcase_37 | AC | 52 ms
60,544 KB |
testcase_38 | AC | 50 ms
60,416 KB |
testcase_39 | AC | 48 ms
60,672 KB |
testcase_40 | AC | 49 ms
60,288 KB |
testcase_41 | AC | 49 ms
60,544 KB |
testcase_42 | AC | 49 ms
60,288 KB |
testcase_43 | WA | - |
testcase_44 | AC | 51 ms
61,952 KB |
testcase_45 | AC | 52 ms
62,336 KB |
testcase_46 | WA | - |
testcase_47 | AC | 57 ms
63,232 KB |
testcase_48 | AC | 63 ms
66,304 KB |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | AC | 64 ms
69,376 KB |
testcase_53 | WA | - |
testcase_54 | AC | 64 ms
68,352 KB |
testcase_55 | AC | 62 ms
67,968 KB |
testcase_56 | AC | 49 ms
61,056 KB |
testcase_57 | WA | - |
testcase_58 | AC | 61 ms
66,688 KB |
testcase_59 | AC | 50 ms
60,672 KB |
testcase_60 | WA | - |
testcase_61 | AC | 61 ms
67,712 KB |
testcase_62 | AC | 51 ms
60,928 KB |
testcase_63 | WA | - |
testcase_64 | AC | 103 ms
78,208 KB |
testcase_65 | AC | 131 ms
82,348 KB |
testcase_66 | WA | - |
testcase_67 | WA | - |
testcase_68 | AC | 129 ms
81,024 KB |
testcase_69 | AC | 132 ms
82,688 KB |
testcase_70 | AC | 110 ms
78,544 KB |
testcase_71 | AC | 107 ms
77,824 KB |
testcase_72 | WA | - |
testcase_73 | WA | - |
testcase_74 | AC | 128 ms
82,176 KB |
testcase_75 | AC | 124 ms
80,144 KB |
testcase_76 | WA | - |
testcase_77 | WA | - |
testcase_78 | WA | - |
testcase_79 | AC | 140 ms
84,004 KB |
testcase_80 | WA | - |
testcase_81 | AC | 140 ms
83,456 KB |
testcase_82 | AC | 135 ms
82,816 KB |
testcase_83 | AC | 433 ms
135,476 KB |
testcase_84 | WA | - |
testcase_85 | WA | - |
testcase_86 | AC | 334 ms
117,844 KB |
testcase_87 | WA | - |
testcase_88 | AC | 148 ms
86,784 KB |
testcase_89 | WA | - |
testcase_90 | WA | - |
testcase_91 | WA | - |
testcase_92 | WA | - |
testcase_93 | WA | - |
testcase_94 | AC | 328 ms
115,084 KB |
testcase_95 | WA | - |
testcase_96 | AC | 404 ms
134,600 KB |
testcase_97 | WA | - |
testcase_98 | WA | - |
testcase_99 | WA | - |
testcase_100 | WA | - |
testcase_101 | AC | 173 ms
92,616 KB |
testcase_102 | AC | 147 ms
85,100 KB |
testcase_103 | AC | 185 ms
92,792 KB |
testcase_104 | AC | 206 ms
94,776 KB |
testcase_105 | AC | 350 ms
118,168 KB |
testcase_106 | AC | 234 ms
98,764 KB |
testcase_107 | AC | 382 ms
131,196 KB |
testcase_108 | AC | 415 ms
135,704 KB |
testcase_109 | WA | - |
testcase_110 | AC | 315 ms
115,460 KB |
testcase_111 | AC | 329 ms
117,480 KB |
testcase_112 | AC | 193 ms
93,580 KB |
testcase_113 | WA | - |
testcase_114 | AC | 241 ms
98,552 KB |
testcase_115 | AC | 153 ms
87,040 KB |
testcase_116 | WA | - |
testcase_117 | AC | 206 ms
94,848 KB |
testcase_118 | AC | 402 ms
126,752 KB |
testcase_119 | AC | 266 ms
104,656 KB |
testcase_120 | AC | 396 ms
125,676 KB |
testcase_121 | AC | 185 ms
94,736 KB |
testcase_122 | AC | 259 ms
101,344 KB |
testcase_123 | AC | 52 ms
60,288 KB |
testcase_124 | TLE | - |
testcase_125 | -- | - |
ソースコード
import sys,os,io input = sys.stdin.readline from collections import defaultdict class Graph: def __init__(self, N): self.V = N self.edge = [[] for _ in range(self.V)] self.edges = defaultdict(lambda: 0) self.visited = [0]*N self.parent = [N]*N def add_edge(self, a, b, i): self.edge[a].append(b) self.edges[(a,b)] = i def dfs(self, start): stack = [start] self.parent[start] = -1 self.visited[start] = 1 #記録したい値の配列を定義 while stack: v = stack[-1] for u,i in self.edge[v]: if u==self.parent[v]: continue if self.parent[u]==N: #子へ降ろす self.parent[u]=v stack.append(u) break else: return u else: stack.pop() def bfs1(self, start): stack = deque([start]) self.parent[start] = -1 while stack: v = stack.pop() for u in self.edge[v]: if u==self.parent[v]: continue if self.parent[u]!=N: return u self.parent[u]=v #頂点に対する処理 stack.append(u) return def bfs(self, start): d = deque() d.append([[start],{start:True}]) cyc = [] cnt = 0 while len(d)>0 and cnt<N+10: vs, tf = d.popleft() for w in self.edge[vs[-1]]: if len(vs)>1 and w==vs[-2]: continue lis,dic = copy(vs), copy(tf) lis.append(w) dic[w] = True if w==start and len(lis)>len(cyc): cyc = lis elif w not in tf: d.append([lis,dic]) cnt += 1 return cyc from collections import deque from copy import copy N = int(input()) G = Graph(N) for i in range(N): a,b = map(int, input().split()) a,b = min(a-1,b-1), max(a-1,b-1) G.add_edge(a,b,i+1) G.add_edge(b,a,i+1) ans = set() cyc = G.bfs1(0) vs = G.bfs(cyc) for v0,v1 in zip(vs[:-1],vs[1:]): ans.add(G.edges[(v0,v1)]) ans = list(ans) print(len(ans)) print(*ans)