Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MarmaladeKnight/d6097b38ade72a764a8b163980f97a0d to your computer and use it in GitHub Desktop.
Save MarmaladeKnight/d6097b38ade72a764a8b163980f97a0d to your computer and use it in GitHub Desktop.
n = int(input())
m = int(input())
wires = []
for i in range(m):
wire = list(map(int, input().split()))
wires.append(wire)
broken_count = int(input())
broken_wires = list(map(int, input().split(' ')))
tmp = -1
m = ''
for broken_wire_number in broken_wires:
wires.remove(wires[broken_wire_number + tmp])
tmp -= 1
tmp_wires = wires[:]
_locals = [[]]
j = 0
while tmp_wires:
if j >= len(_locals):
_locals.append([])
_locals[j].append(tmp_wires[0][0])
for serv in _locals[j]:
for tmp_wire in tmp_wires:
if (tmp_wire[0] == serv):
if _locals[j].count(tmp_wire[1]) == 0:
_locals[j].append(tmp_wire[1])
tmp_wires.remove(tmp_wire)
elif (tmp_wire[1] == serv):
if _locals[j].count(tmp_wire[0]) == 0:
_locals[j].append(tmp_wire[0])
tmp_wires.remove(tmp_wire)
j += 1
k = 0
for var in range(len(_locals)):
k += len(_locals[var])
k = n - k
m += str(len(_locals) + k) + " "
print(m)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment