Submission #1011082

# Submission time Handle Problem Language Result Execution time Memory
1011082 2024-06-29T18:44:22 Z aaaaaarroz Closing Time (IOI23_closing) C++17
35 / 100
1000 ms 50012 KB
    #include "closing.h"
    #include <bits/stdc++.h>
    using namespace std;
    using i64 = long long;
    int max_score(int n, int x, int y, long long k, vector<int> U, vector<int> V, vector<int> W) {
        vector<vector<pair<int, int>>> adj(n);
        for (int i = 0; i < n - 1; ++i) {
            adj[U[i]].push_back({V[i], W[i]});
            adj[V[i]].push_back({U[i], W[i]});
        }
        vector<vector<i64>> dis(n, vector<i64>(2, 0));
        function<void(int, int, int)> dfs = [&](int u, int p, int t) {
            for (auto [v, w] : adj[u]) {
                if (v == p) continue;
                dis[v][t] = dis[u][t] + w;
                dfs(v, u, t);
            }
        };
        dfs(x, -1, 0);
        dfs(y, -1, 1);
        int ans = 2;
        vector<vector<int>> used(n, vector<int>(2, 0));
        used[x][0] = 1;
        used[y][1] = 1;
        for (int c = 1; c <= 2 * n; ++c) {
            i64 mn = 1e18;
            int from, type;
            for (int u = 0; u < n; ++u) {
                for (auto [v, w] : adj[u]) {
                    for (int t = 0; t <= 1; ++t) {
                        if (used[v][t] && used[u][t] == 0) {
                            if (mn > dis[u][t]) {
                                from = u;
                                type = t;
                            }
                            mn = min(mn, dis[u][t]);
                        }
                    }
                }
            }
            if (mn <= k) {
                k -= mn;
                used[from][type] = 1;
                dis[from][!type] -= mn;
                ++ans;
            } 
            else {
                break;
            }
        }
        return ans;
    }

Compilation message

closing.cpp: In function 'int max_score(int, int, int, long long int, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:43:32: warning: 'type' may be used uninitialized in this function [-Wmaybe-uninitialized]
   43 |                 used[from][type] = 1;
      |                                ^
closing.cpp:43:26: warning: 'from' may be used uninitialized in this function [-Wmaybe-uninitialized]
   43 |                 used[from][type] = 1;
      |                          ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1031 ms 50012 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 432 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 432 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 2 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 432 KB Output is correct
24 Correct 1 ms 436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 432 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 2 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 432 KB Output is correct
24 Correct 1 ms 436 KB Output is correct
25 Correct 2 ms 344 KB Output is correct
26 Correct 49 ms 1116 KB Output is correct
27 Correct 2 ms 1112 KB Output is correct
28 Correct 55 ms 1116 KB Output is correct
29 Correct 45 ms 1116 KB Output is correct
30 Correct 2 ms 1112 KB Output is correct
31 Correct 23 ms 1364 KB Output is correct
32 Correct 19 ms 1112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Incorrect 0 ms 436 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Incorrect 0 ms 436 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 432 KB Output is correct
25 Correct 1 ms 436 KB Output is correct
26 Incorrect 0 ms 436 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 432 KB Output is correct
25 Correct 1 ms 436 KB Output is correct
26 Correct 2 ms 344 KB Output is correct
27 Correct 49 ms 1116 KB Output is correct
28 Correct 2 ms 1112 KB Output is correct
29 Correct 55 ms 1116 KB Output is correct
30 Correct 45 ms 1116 KB Output is correct
31 Correct 2 ms 1112 KB Output is correct
32 Correct 23 ms 1364 KB Output is correct
33 Correct 19 ms 1112 KB Output is correct
34 Incorrect 0 ms 436 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
35 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 432 KB Output is correct
25 Correct 1 ms 436 KB Output is correct
26 Correct 2 ms 344 KB Output is correct
27 Correct 49 ms 1116 KB Output is correct
28 Correct 2 ms 1112 KB Output is correct
29 Correct 55 ms 1116 KB Output is correct
30 Correct 45 ms 1116 KB Output is correct
31 Correct 2 ms 1112 KB Output is correct
32 Correct 23 ms 1364 KB Output is correct
33 Correct 19 ms 1112 KB Output is correct
34 Incorrect 0 ms 436 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
35 Halted 0 ms 0 KB -