| Task: | Airport |
| Sender: | aalto25h_005 |
| Submission time: | 2025-10-22 17:41:42 +0300 |
| Language: | C++ (C++17) |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | details |
| #2 | ACCEPTED | 0.00 s | details |
| #3 | ACCEPTED | 0.00 s | details |
| #4 | ACCEPTED | 0.00 s | details |
| #5 | ACCEPTED | 0.00 s | details |
| #6 | ACCEPTED | 0.08 s | details |
| #7 | ACCEPTED | 0.01 s | details |
| #8 | ACCEPTED | 0.05 s | details |
| #9 | ACCEPTED | 0.08 s | details |
| #10 | ACCEPTED | 0.03 s | details |
| #11 | ACCEPTED | 0.00 s | details |
| #12 | ACCEPTED | 0.00 s | details |
| #13 | WRONG ANSWER | 0.00 s | details |
Code
#include <algorithm>
#include <iostream>
#include <limits>
#include <vector>
const int N = 101;
std::vector<int> adj[N];
long long capPerCheckpoint[N];
long long dfsWithFlow(int u, long long flow, int t, bool visited[N], long long capacity[N][N]) {
if (u == t) return flow;
visited[u] = true;
for (int v : adj[u]) {
if (!visited[v] && capacity[u][v] > 0) {
long long pushed = dfsWithFlow(v, std::min(flow, capacity[u][v]), t, visited, capacity);
if (pushed > 0) {
capacity[u][v] -= pushed;
capacity[v][u] += pushed;
return pushed;
}
}
}
return 0; // no flow
}
long long maxflow(int s, int t, long long capacity[N][N]) {
long long flow = 0;
// push till no augmenting path is availabl
while (true) {
bool visited[N] = {false};
long long pushed = dfsWithFlow(s, std::numeric_limits<long long>::max(), t, visited, capacity);
if (pushed == 0) break;
flow += pushed;
}
return flow;
}
int main() {
int n, m;
std::cin >> n >> m;
int s = 1;
int t = n;
for (int i = 0; i < n; ++i) {
std::cin >> capPerCheckpoint[i+1];
if (capPerCheckpoint[i+1] == -1) capPerCheckpoint[i+1] = std::numeric_limits<long long>::max();
}
long long capacityA[N][N] = {{0}};
long long capacityB[N][N] = {{0}};
for (int i = 0; i < m; ++i) {
int a, b;
std::cin >> a >> b;
adj[a].push_back(b);
adj[b].push_back(a); //residual graph
capacityA[a][b] = capPerCheckpoint[a];
capacityB[a][b] = capPerCheckpoint[b];
}
long long f1 = maxflow(s, t, capacityA);
long long f2 = maxflow(s, t, capacityB);
std::cout << std::min(f1, f2) << "\n";
}
Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 10 20 -1 85 7 19 90 72 11 46 65 -1 6 7 9 7 8 4 ... |
| correct output |
|---|
| 7 |
| user output |
|---|
| 7 |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 10 20 -1 80 77 57 77 95 63 98 30 -1 6 7 8 9 7 8 ... |
| correct output |
|---|
| 30 |
| user output |
|---|
| 30 |
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: ACCEPTED
| input |
|---|
| 100 1000 -1 425576195 274150382 1021768... |
| correct output |
|---|
| 6091126630 |
| user output |
|---|
| 6091126630 |
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: ACCEPTED
| input |
|---|
| 100 1000 -1 763842763 612011030 4532521... |
| correct output |
|---|
| 3342235784 |
| user output |
|---|
| 3342235784 |
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: WRONG ANSWER
| input |
|---|
| 7 8 -1 1 1 1 1 1 -1 1 2 1 3 2 4 ... |
| correct output |
|---|
| 1 |
| user output |
|---|
| 2 |
Feedback: Incorrect character on line 1 col 1: expected "1", got "2"
