Submission details
Task:Airport
Sender:aalto25h_001
Submission time:2025-10-22 18:14:02 +0300
Language:C++ (C++17)
Status:READY
Result:
Test results
testverdicttime
#10.00 sdetails
#2ACCEPTED0.00 sdetails
#30.00 sdetails
#4--details
#5ACCEPTED0.00 sdetails
#6--details
#7--details
#8--details
#9--details
#10--details
#11ACCEPTED0.00 sdetails
#12ACCEPTED0.00 sdetails
#13ACCEPTED0.00 sdetails

Code

#include <bits/stdc++.h>

using namespace std;

const int N = 101;
vector<vector<pair<int, int&>>> adj(N);

int vis[N];
int lim[2*N];

int dfs(int n, int t, int& w) {
    if(n == t) return w;
    
    vis[n] = 1;
 
    for(auto& [e, wn] : adj[n]) {
        if(!vis[e] && wn > 0) {
            int b = dfs(e, t, w < wn ? w : wn);
            if(b > 0 && b != INT_MAX) {
                wn -= b;
                for(auto& [node, cap] : adj[e]) {
                    if(node == n) {
                        cap += b;
                        break;
                    }
                }
                return b; 
            }
        }
    }

    return 0;
}

int main () {
    int n, m;
    cin >> n >> m;

    for(int i=1; i <= n; i++) {
        int f; cin >> f;
        lim[i] = (f != -1) ? f : INT_MAX;
    }

    for(int j=1; j <= m; j++) {
        int a, b;
        cin >> a >> b;
        adj[a].push_back({b, lim[a]});
        adj[b].push_back({a, lim[N+a]});
    }

    long long mf = 0;

    while(true) {
        memset(vis, 0, sizeof(vis));
        int f = dfs(1, n, lim[1]);
        if(f == 0) break;
        mf += f;
    }

    cout << mf << '\n';

}

Test details

Test 1

Verdict:

input
10 20
-1 85 7 19 90 72 11 46 65 -1
6 7
9 7
8 4
...

correct output
7

user output
23

Feedback: Incorrect character on line 1 col 1: expected "7", got "23"

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:

input
10 20
-1 63 16 42 62 70 9 94 68 -1
10 9
6 8
10 6
...

correct output
25

user output
68

Feedback: Incorrect character on line 1 col 1: expected "25", got "68"

Test 4

Verdict:

input
10 20
-1 3 86 -1 32 34 9 50 -1 -1
6 7
7 8
9 2
...

correct output
3

user output
(empty)

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:

input
100 1000
-1 425576195 274150382 1021768...

correct output
6091126630

user output
(empty)

Test 7

Verdict:

input
100 1000
-1 769953265 -1 389517741 2323...

correct output
769953265

user output
(empty)

Test 8

Verdict:

input
100 1000
-1 584988267 763129662 6781413...

correct output
1699511766

user output
(empty)

Test 9

Verdict:

input
100 1000
-1 921671366 121044688 2933366...

correct output
1805833567

user output
(empty)

Test 10

Verdict:

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