結果
問題 | No.1254 補強への架け橋 |
ユーザー | marroncastle |
提出日時 | 2020-10-10 01:02:36 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,076 bytes |
コンパイル時間 | 155 ms |
コンパイル使用メモリ | 82,100 KB |
実行使用メモリ | 282,476 KB |
最終ジャッジ日時 | 2024-07-20 15:09:50 |
合計ジャッジ時間 | 32,270 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
65,920 KB |
testcase_01 | AC | 50 ms
60,160 KB |
testcase_02 | AC | 50 ms
60,928 KB |
testcase_03 | AC | 51 ms
60,160 KB |
testcase_04 | AC | 52 ms
60,672 KB |
testcase_05 | AC | 51 ms
60,416 KB |
testcase_06 | AC | 50 ms
60,160 KB |
testcase_07 | AC | 51 ms
60,672 KB |
testcase_08 | AC | 51 ms
60,672 KB |
testcase_09 | AC | 52 ms
60,416 KB |
testcase_10 | AC | 51 ms
60,416 KB |
testcase_11 | AC | 51 ms
60,928 KB |
testcase_12 | AC | 50 ms
59,904 KB |
testcase_13 | AC | 51 ms
60,928 KB |
testcase_14 | AC | 51 ms
60,672 KB |
testcase_15 | AC | 50 ms
60,800 KB |
testcase_16 | AC | 50 ms
60,288 KB |
testcase_17 | AC | 50 ms
60,544 KB |
testcase_18 | AC | 51 ms
60,800 KB |
testcase_19 | AC | 49 ms
60,672 KB |
testcase_20 | AC | 51 ms
60,416 KB |
testcase_21 | AC | 51 ms
60,416 KB |
testcase_22 | AC | 49 ms
60,800 KB |
testcase_23 | AC | 53 ms
61,056 KB |
testcase_24 | AC | 51 ms
61,312 KB |
testcase_25 | AC | 51 ms
60,160 KB |
testcase_26 | AC | 53 ms
61,312 KB |
testcase_27 | AC | 52 ms
60,544 KB |
testcase_28 | AC | 52 ms
61,056 KB |
testcase_29 | AC | 52 ms
60,416 KB |
testcase_30 | AC | 51 ms
60,288 KB |
testcase_31 | AC | 52 ms
61,056 KB |
testcase_32 | AC | 51 ms
60,672 KB |
testcase_33 | AC | 52 ms
61,312 KB |
testcase_34 | AC | 52 ms
61,500 KB |
testcase_35 | AC | 52 ms
60,544 KB |
testcase_36 | AC | 52 ms
61,312 KB |
testcase_37 | AC | 50 ms
61,056 KB |
testcase_38 | AC | 51 ms
60,544 KB |
testcase_39 | AC | 52 ms
60,800 KB |
testcase_40 | AC | 52 ms
60,928 KB |
testcase_41 | AC | 51 ms
60,544 KB |
testcase_42 | AC | 50 ms
60,544 KB |
testcase_43 | AC | 73 ms
71,552 KB |
testcase_44 | AC | 60 ms
65,664 KB |
testcase_45 | AC | 62 ms
66,688 KB |
testcase_46 | AC | 73 ms
70,144 KB |
testcase_47 | AC | 64 ms
67,456 KB |
testcase_48 | AC | 68 ms
69,504 KB |
testcase_49 | AC | 52 ms
61,440 KB |
testcase_50 | AC | 72 ms
72,884 KB |
testcase_51 | AC | 71 ms
71,296 KB |
testcase_52 | AC | 71 ms
72,320 KB |
testcase_53 | AC | 71 ms
71,552 KB |
testcase_54 | AC | 73 ms
72,064 KB |
testcase_55 | AC | 68 ms
70,272 KB |
testcase_56 | AC | 53 ms
62,080 KB |
testcase_57 | AC | 65 ms
68,736 KB |
testcase_58 | AC | 67 ms
69,632 KB |
testcase_59 | AC | 53 ms
61,824 KB |
testcase_60 | AC | 58 ms
64,768 KB |
testcase_61 | AC | 72 ms
72,192 KB |
testcase_62 | AC | 54 ms
61,952 KB |
testcase_63 | AC | 129 ms
80,476 KB |
testcase_64 | AC | 102 ms
77,952 KB |
testcase_65 | AC | 116 ms
78,848 KB |
testcase_66 | AC | 108 ms
78,464 KB |
testcase_67 | AC | 93 ms
77,568 KB |
testcase_68 | AC | 113 ms
78,592 KB |
testcase_69 | AC | 117 ms
79,488 KB |
testcase_70 | AC | 104 ms
78,628 KB |
testcase_71 | AC | 98 ms
78,472 KB |
testcase_72 | AC | 120 ms
80,000 KB |
testcase_73 | AC | 97 ms
78,084 KB |
testcase_74 | AC | 105 ms
78,592 KB |
testcase_75 | AC | 108 ms
79,104 KB |
testcase_76 | AC | 85 ms
77,412 KB |
testcase_77 | AC | 108 ms
78,592 KB |
testcase_78 | AC | 120 ms
80,064 KB |
testcase_79 | AC | 124 ms
79,872 KB |
testcase_80 | AC | 116 ms
79,744 KB |
testcase_81 | AC | 128 ms
79,744 KB |
testcase_82 | AC | 122 ms
79,872 KB |
testcase_83 | AC | 598 ms
159,652 KB |
testcase_84 | AC | 560 ms
155,440 KB |
testcase_85 | AC | 290 ms
103,144 KB |
testcase_86 | AC | 434 ms
123,936 KB |
testcase_87 | AC | 528 ms
149,720 KB |
testcase_88 | AC | 148 ms
82,460 KB |
testcase_89 | AC | 553 ms
151,056 KB |
testcase_90 | AC | 329 ms
109,232 KB |
testcase_91 | AC | 285 ms
101,372 KB |
testcase_92 | AC | 198 ms
89,344 KB |
testcase_93 | AC | 363 ms
108,824 KB |
testcase_94 | AC | 412 ms
123,516 KB |
testcase_95 | AC | 410 ms
120,708 KB |
testcase_96 | AC | 522 ms
142,216 KB |
testcase_97 | AC | 258 ms
95,712 KB |
testcase_98 | AC | 554 ms
146,104 KB |
testcase_99 | AC | 352 ms
111,836 KB |
testcase_100 | AC | 590 ms
160,300 KB |
testcase_101 | AC | 167 ms
84,480 KB |
testcase_102 | AC | 136 ms
81,024 KB |
testcase_103 | AC | 170 ms
86,408 KB |
testcase_104 | AC | 173 ms
88,088 KB |
testcase_105 | AC | 394 ms
122,392 KB |
testcase_106 | AC | 269 ms
97,868 KB |
testcase_107 | AC | 539 ms
157,048 KB |
testcase_108 | AC | 509 ms
144,724 KB |
testcase_109 | AC | 338 ms
111,560 KB |
testcase_110 | AC | 401 ms
119,824 KB |
testcase_111 | AC | 381 ms
119,108 KB |
testcase_112 | AC | 216 ms
91,400 KB |
testcase_113 | AC | 398 ms
126,316 KB |
testcase_114 | AC | 199 ms
91,704 KB |
testcase_115 | AC | 146 ms
83,372 KB |
testcase_116 | AC | 311 ms
106,780 KB |
testcase_117 | AC | 200 ms
92,424 KB |
testcase_118 | AC | 459 ms
131,368 KB |
testcase_119 | AC | 306 ms
106,780 KB |
testcase_120 | AC | 515 ms
138,708 KB |
testcase_121 | AC | 190 ms
87,832 KB |
testcase_122 | AC | 288 ms
102,192 KB |
testcase_123 | AC | 50 ms
60,292 KB |
testcase_124 | TLE | - |
testcase_125 | -- | - |
ソースコード
import sys,os,io input = sys.stdin.readline class Graph: def __init__(self, N): self.V = N self.edge = [[] for _ in range(self.V)] self.edges = [0]*(N*2+1) self.visited = [0]*N self.parent = [N]*N def add_edge(self, a, b, i): self.edge[a].append((b,i)) self.edges[i] = (a,b) 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 = [start] self.parent[start] = -1 while stack: v = stack.pop() for u,i 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(dict()) cyc = dict() cnt = 0 while len(d)>0 and cnt<2*N: es = d.popleft() if len(es): v0,v = self.edges[list(es.keys())[-1]] else: v0,v = start,start for w,i in self.edge[v]: if w==v0: continue if i not in es: dic = copy(es) dic[i] = True if w==start: for i in range(N+1,2*N+1): if i in dic: dic[i-N] = True del dic[i] if len(dic)>len(cyc): cyc = dic else: d.append(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()) G.add_edge(a-1,b-1,i+1) G.add_edge(b-1,a-1,N+i+1) ans = set() cyc = G.bfs1(0) es = G.bfs(cyc) for e in es.keys(): ans.add(e) ans = list(ans) print(len(ans)) print(*ans)