結果
問題 | No.1254 補強への架け橋 |
ユーザー | marroncastle |
提出日時 | 2020-10-10 01:01:35 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,076 bytes |
コンパイル時間 | 154 ms |
コンパイル使用メモリ | 82,196 KB |
実行使用メモリ | 282,240 KB |
最終ジャッジ日時 | 2024-07-20 15:08:22 |
合計ジャッジ時間 | 32,581 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
66,560 KB |
testcase_01 | AC | 49 ms
60,672 KB |
testcase_02 | AC | 50 ms
60,416 KB |
testcase_03 | AC | 50 ms
60,672 KB |
testcase_04 | AC | 49 ms
60,672 KB |
testcase_05 | AC | 47 ms
60,544 KB |
testcase_06 | AC | 49 ms
60,416 KB |
testcase_07 | AC | 49 ms
60,288 KB |
testcase_08 | AC | 50 ms
60,544 KB |
testcase_09 | AC | 48 ms
60,800 KB |
testcase_10 | AC | 53 ms
60,416 KB |
testcase_11 | AC | 48 ms
60,672 KB |
testcase_12 | AC | 47 ms
60,288 KB |
testcase_13 | AC | 50 ms
61,056 KB |
testcase_14 | AC | 49 ms
60,928 KB |
testcase_15 | AC | 49 ms
60,800 KB |
testcase_16 | AC | 48 ms
60,544 KB |
testcase_17 | AC | 48 ms
60,672 KB |
testcase_18 | AC | 48 ms
60,288 KB |
testcase_19 | AC | 51 ms
60,416 KB |
testcase_20 | AC | 52 ms
61,056 KB |
testcase_21 | AC | 56 ms
60,544 KB |
testcase_22 | AC | 54 ms
60,544 KB |
testcase_23 | AC | 55 ms
60,672 KB |
testcase_24 | AC | 56 ms
61,440 KB |
testcase_25 | AC | 54 ms
61,184 KB |
testcase_26 | AC | 56 ms
61,696 KB |
testcase_27 | AC | 57 ms
60,672 KB |
testcase_28 | AC | 50 ms
61,056 KB |
testcase_29 | AC | 49 ms
60,416 KB |
testcase_30 | AC | 55 ms
60,544 KB |
testcase_31 | AC | 49 ms
61,056 KB |
testcase_32 | AC | 48 ms
60,416 KB |
testcase_33 | AC | 52 ms
61,824 KB |
testcase_34 | AC | 51 ms
61,696 KB |
testcase_35 | AC | 50 ms
60,928 KB |
testcase_36 | AC | 50 ms
61,440 KB |
testcase_37 | AC | 50 ms
60,928 KB |
testcase_38 | AC | 49 ms
60,876 KB |
testcase_39 | AC | 50 ms
60,416 KB |
testcase_40 | AC | 55 ms
60,544 KB |
testcase_41 | AC | 53 ms
60,928 KB |
testcase_42 | AC | 51 ms
60,968 KB |
testcase_43 | AC | 70 ms
71,808 KB |
testcase_44 | AC | 58 ms
66,176 KB |
testcase_45 | AC | 58 ms
66,432 KB |
testcase_46 | AC | 66 ms
70,016 KB |
testcase_47 | AC | 68 ms
67,584 KB |
testcase_48 | AC | 72 ms
70,016 KB |
testcase_49 | AC | 51 ms
61,696 KB |
testcase_50 | AC | 71 ms
72,576 KB |
testcase_51 | AC | 68 ms
71,424 KB |
testcase_52 | AC | 71 ms
71,808 KB |
testcase_53 | AC | 71 ms
71,424 KB |
testcase_54 | AC | 71 ms
72,320 KB |
testcase_55 | AC | 69 ms
70,016 KB |
testcase_56 | AC | 51 ms
62,080 KB |
testcase_57 | AC | 63 ms
69,200 KB |
testcase_58 | AC | 66 ms
70,144 KB |
testcase_59 | AC | 50 ms
61,568 KB |
testcase_60 | AC | 55 ms
65,664 KB |
testcase_61 | AC | 69 ms
71,552 KB |
testcase_62 | AC | 54 ms
62,208 KB |
testcase_63 | AC | 135 ms
80,128 KB |
testcase_64 | AC | 99 ms
78,136 KB |
testcase_65 | AC | 113 ms
79,104 KB |
testcase_66 | AC | 107 ms
79,104 KB |
testcase_67 | AC | 90 ms
77,824 KB |
testcase_68 | AC | 112 ms
78,704 KB |
testcase_69 | AC | 132 ms
79,744 KB |
testcase_70 | AC | 102 ms
78,208 KB |
testcase_71 | AC | 97 ms
78,336 KB |
testcase_72 | AC | 120 ms
80,000 KB |
testcase_73 | AC | 96 ms
78,172 KB |
testcase_74 | AC | 107 ms
79,088 KB |
testcase_75 | AC | 110 ms
78,844 KB |
testcase_76 | AC | 92 ms
77,568 KB |
testcase_77 | AC | 120 ms
78,876 KB |
testcase_78 | AC | 128 ms
80,080 KB |
testcase_79 | AC | 134 ms
79,900 KB |
testcase_80 | AC | 124 ms
79,788 KB |
testcase_81 | AC | 136 ms
80,132 KB |
testcase_82 | AC | 121 ms
79,972 KB |
testcase_83 | AC | 630 ms
159,784 KB |
testcase_84 | AC | 577 ms
155,508 KB |
testcase_85 | AC | 333 ms
103,484 KB |
testcase_86 | AC | 464 ms
124,144 KB |
testcase_87 | AC | 570 ms
149,696 KB |
testcase_88 | AC | 144 ms
82,740 KB |
testcase_89 | AC | 583 ms
151,328 KB |
testcase_90 | AC | 354 ms
109,440 KB |
testcase_91 | AC | 309 ms
101,700 KB |
testcase_92 | AC | 217 ms
89,600 KB |
testcase_93 | AC | 384 ms
109,220 KB |
testcase_94 | AC | 439 ms
123,720 KB |
testcase_95 | AC | 428 ms
121,220 KB |
testcase_96 | AC | 549 ms
142,944 KB |
testcase_97 | AC | 269 ms
95,768 KB |
testcase_98 | AC | 565 ms
145,852 KB |
testcase_99 | AC | 359 ms
111,712 KB |
testcase_100 | AC | 611 ms
160,800 KB |
testcase_101 | AC | 173 ms
84,736 KB |
testcase_102 | AC | 137 ms
81,536 KB |
testcase_103 | AC | 183 ms
86,272 KB |
testcase_104 | AC | 203 ms
88,480 KB |
testcase_105 | AC | 451 ms
122,720 KB |
testcase_106 | AC | 287 ms
97,784 KB |
testcase_107 | AC | 600 ms
157,012 KB |
testcase_108 | AC | 576 ms
144,668 KB |
testcase_109 | AC | 377 ms
111,796 KB |
testcase_110 | AC | 437 ms
119,772 KB |
testcase_111 | AC | 431 ms
119,440 KB |
testcase_112 | AC | 227 ms
91,092 KB |
testcase_113 | AC | 441 ms
126,576 KB |
testcase_114 | AC | 215 ms
91,836 KB |
testcase_115 | AC | 147 ms
83,456 KB |
testcase_116 | AC | 327 ms
107,472 KB |
testcase_117 | AC | 297 ms
92,400 KB |
testcase_118 | AC | 498 ms
131,000 KB |
testcase_119 | AC | 337 ms
107,244 KB |
testcase_120 | AC | 547 ms
138,848 KB |
testcase_121 | AC | 199 ms
88,516 KB |
testcase_122 | AC | 318 ms
102,708 KB |
testcase_123 | AC | 49 ms
60,928 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<3*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)