| Task: | Airport |
| Sender: | aalto25h_002 |
| Submission time: | 2025-10-22 17:48:18 +0300 |
| Language: | Python3 (CPython3) |
| Status: | READY |
| Result: | TIME LIMIT EXCEEDED |
| test | verdict | time | |
|---|---|---|---|
| #1 | TIME LIMIT EXCEEDED | -- | details |
| #2 | TIME LIMIT EXCEEDED | -- | details |
| #3 | ACCEPTED | 0.02 s | details |
| #4 | ACCEPTED | 0.02 s | details |
| #5 | ACCEPTED | 0.02 s | details |
| #6 | TIME LIMIT EXCEEDED | -- | details |
| #7 | ACCEPTED | 0.02 s | details |
| #8 | ACCEPTED | 0.02 s | details |
| #9 | ACCEPTED | 0.02 s | details |
| #10 | TIME LIMIT EXCEEDED | -- | details |
| #11 | ACCEPTED | 0.02 s | details |
| #12 | ACCEPTED | 0.02 s | details |
| #13 | ACCEPTED | 0.02 s | details |
Code
import heapq
n,m = [int(x) for x in input().split()]
hall_capacity = [int(x) for x in input().split()]
neighbors = []
for i in range(n):
neighbors.append([])
for i in range (m):
a,b = [int(x) for x in input().split()]
neighbors[a-1].append(b-1)
def find_path():
priority_queue = []
heapq.heappush(priority_queue,[0,[-1,0]]) # tuple = (distance,current_node)
path = [-1 for i in range (n)]
while priority_queue:
dist,nodes = heapq.heappop(priority_queue)
previous_node,node = nodes
while path[node]!=-1 and priority_queue:
dist,nodes = heapq.heappop(priority_queue)
previous_node,node = nodes
if path[node]!=-1:
#ON TROUVE PAS DE CHEMIN
return [],0
path[node]=previous_node
for neigh in neighbors[node]:
if path[neigh] == -1 and hall_capacity[neigh] != 0:
if neigh == n-1 :
curr_node = n-1
if hall_capacity[curr_node] <= -1:
min_value = float('inf')
else:
min_value = hall_capacity[curr_node]
path[n-1]=node
chemin = []
while curr_node != -1:
chemin.append(curr_node)
if hall_capacity[curr_node] <= -1: capacity = float('inf')
else: capacity = hall_capacity[curr_node]
min_value = min(capacity,min_value)
curr_node = path[curr_node]
return chemin[::-1],min_value
new_dist = dist + 1
heapq.heappush(priority_queue,[new_dist,[node,neigh]])
return [],0
def sub_mini_from_path(path,mini):
for i in range(len(path)):
hall_capacity[path[i]]-=mini
curr_path,mini = find_path()
total_flow = mini
while curr_path:
sub_mini_from_path(curr_path,mini)
curr_path,mini = find_path()
total_flow+=mini
print(total_flow)Test details
Test 1
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 10 20 -1 85 7 19 90 72 11 46 65 -1 6 7 9 7 8 4 ... |
| correct output |
|---|
| 7 |
| user output |
|---|
| (empty) |
Test 2
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 10 20 -1 80 77 57 77 95 63 98 30 -1 6 7 8 9 7 8 ... |
| correct output |
|---|
| 30 |
| user output |
|---|
| (empty) |
Test 3
Verdict: ACCEPTED
| input |
|---|
| 10 20 -1 63 16 42 62 70 9 94 68 -1 10 9 6 8 10 6 ... |
| correct output |
|---|
| 25 |
| user output |
|---|
| 25 |
Test 4
Verdict: ACCEPTED
| input |
|---|
| 10 20 -1 3 86 -1 32 34 9 50 -1 -1 6 7 7 8 9 2 ... |
| correct output |
|---|
| 3 |
| user output |
|---|
| 3 |
Test 5
Verdict: ACCEPTED
| input |
|---|
| 10 20 -1 43 38 -1 7 54 26 97 76 -1 3 9 9 10 6 7 ... |
| correct output |
|---|
| 76 |
| user output |
|---|
| 76 |
Test 6
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 100 1000 -1 425576195 274150382 1021768... |
| correct output |
|---|
| 6091126630 |
| user output |
|---|
| (empty) |
Test 7
Verdict: ACCEPTED
| input |
|---|
| 100 1000 -1 769953265 -1 389517741 2323... |
| correct output |
|---|
| 769953265 |
| user output |
|---|
| 769953265 |
Test 8
Verdict: ACCEPTED
| input |
|---|
| 100 1000 -1 584988267 763129662 6781413... |
| correct output |
|---|
| 1699511766 |
| user output |
|---|
| 1699511766 |
Test 9
Verdict: ACCEPTED
| input |
|---|
| 100 1000 -1 921671366 121044688 2933366... |
| correct output |
|---|
| 1805833567 |
| user output |
|---|
| 1805833567 |
Test 10
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 100 1000 -1 763842763 612011030 4532521... |
| correct output |
|---|
| 3342235784 |
| user output |
|---|
| (empty) |
Test 11
Verdict: ACCEPTED
| input |
|---|
| 3 3
-1 1 -1 1 2 2 3 2 2 |
| correct output |
|---|
| 1 |
| user output |
|---|
| 1 |
Test 12
Verdict: ACCEPTED
| input |
|---|
| 3 4
-1 1 -1 1 2 1 2 2 3 ... |
| correct output |
|---|
| 1 |
| user output |
|---|
| 1 |
Test 13
Verdict: ACCEPTED
| input |
|---|
| 7 8 -1 1 1 1 1 1 -1 1 2 1 3 2 4 ... |
| correct output |
|---|
| 1 |
| user output |
|---|
| 1 |
