Submission #1793754
Source Code Expand
import copy def set(adjacent,edge): for x in edge: adjacent[x[0]].append(x[1]) adjacent[x[1]].append(x[0]) def search(goal,path): n = path[len(path) - 1] if n == goal: print(path) else: for x in adjacent[n]: if x not in path: path.append(x) search(goal, path) path.pop() def search_loop_node(start,path,node_loops): n = path[len(path)-1] for x in adjacent[n]: if x == start and len(path) >=2 and path[-2] != start : path.append(x) node_loops.append(copy.deepcopy(path)) path.pop() elif x not in path: path.append(x) search_loop_node(start, path,loops) path.pop() #入力 N, M = [int(i) for i in input().split()] edge = [] for i in range(M): a,b = [int(i) for i in input().split()] edge.append([a,b]) #辺の生成 adjacent=[ [] for i in range(N+1)] loops=[] set(adjacent,edge) #ループの検索 for i in range(N): search_loop(i,[i],loops) #ループに属する辺(橋でない辺)の検索 for loop in loops: pre_node = loop[0] for node in loop: if pre_node < node and [pre_node, node] not in not_bridge: not_bridge.append([pre_node,node]) #答えは全体の辺の数からループでないものを引いた数 print(M-len(not_bridge))
Submission Info
Submission Time | |
---|---|
Task | C - Bridge |
User | muta |
Language | Python (3.4.3) |
Score | 0 |
Code Size | 1447 Byte |
Status | RE |
Exec Time | 24 ms |
Memory | 3492 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt |
All | sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_1.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_2.txt, subtask_1_3.txt, subtask_1_4.txt, subtask_1_5.txt, subtask_1_6.txt, subtask_1_7.txt, subtask_1_8.txt, subtask_1_9.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | RE | 24 ms | 3492 KB |
sample_02.txt | RE | 23 ms | 3492 KB |
sample_03.txt | RE | 23 ms | 3492 KB |
subtask_1_1.txt | RE | 23 ms | 3492 KB |
subtask_1_10.txt | RE | 23 ms | 3492 KB |
subtask_1_11.txt | RE | 23 ms | 3492 KB |
subtask_1_12.txt | RE | 23 ms | 3492 KB |
subtask_1_13.txt | RE | 23 ms | 3492 KB |
subtask_1_14.txt | RE | 23 ms | 3492 KB |
subtask_1_15.txt | RE | 23 ms | 3492 KB |
subtask_1_16.txt | RE | 23 ms | 3492 KB |
subtask_1_17.txt | RE | 23 ms | 3492 KB |
subtask_1_2.txt | RE | 23 ms | 3492 KB |
subtask_1_3.txt | RE | 23 ms | 3492 KB |
subtask_1_4.txt | RE | 23 ms | 3492 KB |
subtask_1_5.txt | RE | 23 ms | 3492 KB |
subtask_1_6.txt | RE | 23 ms | 3492 KB |
subtask_1_7.txt | RE | 23 ms | 3492 KB |
subtask_1_8.txt | RE | 23 ms | 3492 KB |
subtask_1_9.txt | RE | 23 ms | 3492 KB |