Advertisement
icarussiano

day 25

Dec 25th, 2023 (edited)
956
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.29 KB | None | 0 0
  1. import networkx as nx
  2. graph = nx.Graph([(l.split(':')[0], x) for l in open('input').read().splitlines() for x in l.split(':')[1].strip().split(' ')])
  3. graph.remove_edges_from(nx.minimum_edge_cut(graph))
  4. print(len(list(nx.connected_components(graph))[0])*len(list(nx.connected_components(graph))[1]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement