Task: | Tietoverkko |
Sender: | Kisse |
Submission time: | 2018-01-18 17:14:38 +0200 |
Language: | Python3 |
Status: | READY |
Result: | 28 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 28 |
#2 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.07 s | 1 | details |
#2 | ACCEPTED | 0.07 s | 1 | details |
#3 | ACCEPTED | 0.07 s | 1 | details |
#4 | ACCEPTED | 0.09 s | 1 | details |
#5 | ACCEPTED | 0.08 s | 1 | details |
#6 | TIME LIMIT EXCEEDED | -- | 2 | details |
#7 | TIME LIMIT EXCEEDED | -- | 2 | details |
#8 | TIME LIMIT EXCEEDED | -- | 2 | details |
#9 | TIME LIMIT EXCEEDED | -- | 2 | details |
#10 | TIME LIMIT EXCEEDED | -- | 2 | details |
Code
N = int(input()) NPairs = [] Pairs = [] for I in range(N): Pair = input().split(" ") Pairs.append([int(Pair[0]), int(Pair[1])]) #print("Full network:", Pairs) def GetNumConn(): NumConn = [0 for I in range(N + 1)] for I in range(1, N + 1): for Pair in Pairs: if Pair[0] == I or Pair[1] == I: NumConn[I] += 1 return NumConn def SingleConn(): Changed = False NumConn = GetNumConn() for I in range(1, N + 1): if NumConn[I] == 1: for Pair in Pairs: if Pair[0] == I or Pair[1] == I: NPairs.append(Pair) Pairs.remove(Pair) Changed = True return Changed def MultiConn(): CurrNodes = [] CurrNodes.append([Pairs[0][0], 0]) VisNodes = [] #print("Start node:", CurrNodes[0]) Changed = False while not Changed: NewNode = False for Node in CurrNodes: if not NewNode: #print("Node:", Node) for Pair in Pairs: for I in range(2): if Pair[I] == Node[0] and Pair[(I + 1) % 2] != Node[1]: if Pair[(I + 1) % 2] in VisNodes or Pair[(I + 1) % 2] in CurrNodes: #print("Visited Node:", Pair[(I + 1) % 2]) Pairs.remove(Pair) Changed = True else: #print("New Node:", Pair[(I + 1) % 2]) CurrNodes.append([Pair[(I + 1) % 2], Node[0]]) NewNode = True CurrNodes.remove(Node) VisNodes.append(Node[0]) print(Pairs) for Pair in Pairs: if not Pair in NPairs: NPairs.append(Pair) while 42: if not SingleConn(): break print(len(NPairs))
Test details
Test 1
Group: 1
Verdict: ACCEPTED
input |
---|
100 16 88 6 77 60 92 98 64 ... |
correct output |
---|
97 |
user output |
---|
97 |
Test 2
Group: 1
Verdict: ACCEPTED
input |
---|
100 97 41 95 93 79 60 5 4 ... |
correct output |
---|
95 |
user output |
---|
95 |
Test 3
Group: 1
Verdict: ACCEPTED
input |
---|
100 87 24 21 49 86 85 42 32 ... |
correct output |
---|
90 |
user output |
---|
90 |
Test 4
Group: 1
Verdict: ACCEPTED
input |
---|
100 30 24 54 79 51 6 80 29 ... |
correct output |
---|
50 |
user output |
---|
50 |
Test 5
Group: 1
Verdict: ACCEPTED
input |
---|
100 11 27 54 59 100 90 2 95 ... |
correct output |
---|
0 |
user output |
---|
0 |
Test 6
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 98276 76171 70684 49183 48756 661 17166 16972 ... |
correct output |
---|
99997 |
user output |
---|
(empty) |
Test 7
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 35903 47275 13566 84 58018 42495 57071 4451 ... |
correct output |
---|
99995 |
user output |
---|
(empty) |
Test 8
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 79209 94485 60266 86793 27501 19927 13544 59730 ... |
correct output |
---|
99000 |
user output |
---|
(empty) |
Test 9
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 68402 82703 12892 46068 60013 40753 26168 34434 ... |
correct output |
---|
90000 |
user output |
---|
(empty) |
Test 10
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 37330 74855 54324 45726 61652 15611 79081 47339 ... |
correct output |
---|
0 |
user output |
---|
(empty) |