結果
問題 | No.1254 補強への架け橋 |
ユーザー | marroncastle |
提出日時 | 2020-10-09 23:49:17 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,706 bytes |
コンパイル時間 | 736 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 101,616 KB |
最終ジャッジ日時 | 2024-07-20 14:41:28 |
合計ジャッジ時間 | 21,065 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 49 ms
60,544 KB |
testcase_01 | AC | 53 ms
60,160 KB |
testcase_02 | AC | 48 ms
59,904 KB |
testcase_03 | RE | - |
testcase_04 | AC | 50 ms
60,288 KB |
testcase_05 | AC | 54 ms
60,032 KB |
testcase_06 | AC | 50 ms
60,160 KB |
testcase_07 | AC | 48 ms
60,032 KB |
testcase_08 | RE | - |
testcase_09 | AC | 47 ms
60,160 KB |
testcase_10 | RE | - |
testcase_11 | WA | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | AC | 52 ms
60,416 KB |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | AC | 51 ms
60,288 KB |
testcase_19 | RE | - |
testcase_20 | AC | 53 ms
60,800 KB |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
testcase_31 | RE | - |
testcase_32 | RE | - |
testcase_33 | RE | - |
testcase_34 | RE | - |
testcase_35 | RE | - |
testcase_36 | RE | - |
testcase_37 | RE | - |
testcase_38 | RE | - |
testcase_39 | RE | - |
testcase_40 | RE | - |
testcase_41 | RE | - |
testcase_42 | RE | - |
testcase_43 | RE | - |
testcase_44 | RE | - |
testcase_45 | RE | - |
testcase_46 | RE | - |
testcase_47 | RE | - |
testcase_48 | RE | - |
testcase_49 | RE | - |
testcase_50 | RE | - |
testcase_51 | RE | - |
testcase_52 | RE | - |
testcase_53 | RE | - |
testcase_54 | RE | - |
testcase_55 | RE | - |
testcase_56 | RE | - |
testcase_57 | RE | - |
testcase_58 | RE | - |
testcase_59 | RE | - |
testcase_60 | RE | - |
testcase_61 | RE | - |
testcase_62 | RE | - |
testcase_63 | RE | - |
testcase_64 | RE | - |
testcase_65 | RE | - |
testcase_66 | RE | - |
testcase_67 | RE | - |
testcase_68 | RE | - |
testcase_69 | RE | - |
testcase_70 | RE | - |
testcase_71 | RE | - |
testcase_72 | RE | - |
testcase_73 | RE | - |
testcase_74 | RE | - |
testcase_75 | RE | - |
testcase_76 | RE | - |
testcase_77 | RE | - |
testcase_78 | RE | - |
testcase_79 | RE | - |
testcase_80 | RE | - |
testcase_81 | RE | - |
testcase_82 | RE | - |
testcase_83 | RE | - |
testcase_84 | RE | - |
testcase_85 | RE | - |
testcase_86 | RE | - |
testcase_87 | RE | - |
testcase_88 | RE | - |
testcase_89 | RE | - |
testcase_90 | RE | - |
testcase_91 | RE | - |
testcase_92 | RE | - |
testcase_93 | RE | - |
testcase_94 | RE | - |
testcase_95 | RE | - |
testcase_96 | RE | - |
testcase_97 | RE | - |
testcase_98 | RE | - |
testcase_99 | RE | - |
testcase_100 | RE | - |
testcase_101 | RE | - |
testcase_102 | RE | - |
testcase_103 | RE | - |
testcase_104 | RE | - |
testcase_105 | RE | - |
testcase_106 | RE | - |
testcase_107 | RE | - |
testcase_108 | RE | - |
testcase_109 | RE | - |
testcase_110 | RE | - |
testcase_111 | RE | - |
testcase_112 | RE | - |
testcase_113 | RE | - |
testcase_114 | RE | - |
testcase_115 | RE | - |
testcase_116 | RE | - |
testcase_117 | RE | - |
testcase_118 | RE | - |
testcase_119 | RE | - |
testcase_120 | RE | - |
testcase_121 | RE | - |
testcase_122 | RE | - |
testcase_123 | AC | 50 ms
60,160 KB |
testcase_124 | WA | - |
testcase_125 | WA | - |
ソースコード
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 = [False]*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 #記録したい値の配列を定義 while stack: v = stack.pop() 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 def bfs(self, start): from collections import deque from copy import copy d = deque() d.append(dict()) cyc = dict() cnt = 0 while len(d)>0 and cnt<5*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 w==start: dic = copy(es) dic[i] = True 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 if w not in es: dic = copy(es) dic[i] = True d.append(dic) cnt += 1 return cyc 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.dfs(0) es = G.bfs(cyc) for e in es.keys(): ans.add(e) ans = list(ans) print(len(ans)) print(*ans)