Created
October 31, 2017 05:07
-
-
Save MarmaladeKnight/d6097b38ade72a764a8b163980f97a0d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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