Submission #567522

# Submission time Handle Problem Language Result Execution time Memory
567522 2022-05-23T16:08:21 Z Stickfish Swapping Cities (APIO20_swap) C++17
7 / 100
124 ms 11868 KB
#include "swap.h"
#include <vector>
#include <algorithm>
using namespace std;

const int MAXN = 1e5 + 123;
vector<pair<int, int>> edg[MAXN];
bool abysmaldeg = true;

void init(int n, int m, vector<int> U, vector<int> V, vector<int> W) {
    vector<pair<int, pair<int, int>>> edg_weight(m);
    for (int i = 0; i < m; ++i) {
        edg_weight[i] = {W[i], {U[i], V[i]}};
    }
    sort(edg_weight.begin(), edg_weight.end());
    for (auto [w, e] : edg_weight) {
        auto [u, v] = e;
        edg[u].push_back({v, w});
        edg[v].push_back({u, w});
    }
    for (int i = 0; i < n; ++i)
        abysmaldeg &= edg[i].size() <= 2;
}

int getMinimumFuelCapacity(int X, int Y) {
    if (abysmaldeg)
        return -1;
    if (edg[0].size() < 3)
        return -1;
    if (X == 0) {
        return max(edg[0][2].second, edg[Y][0].second);
    }
    if (Y == 0)
        return getMinimumFuelCapacity(Y, X);
    return max({edg[0][2].second, edg[X][0].second, edg[Y][0].second});
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2516 KB Output is correct
2 Correct 2 ms 2516 KB Output is correct
3 Correct 2 ms 2516 KB Output is correct
4 Correct 3 ms 2656 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 3 ms 2644 KB Output is correct
7 Correct 3 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 44 ms 7836 KB Output is correct
10 Correct 47 ms 9036 KB Output is correct
11 Correct 45 ms 8856 KB Output is correct
12 Correct 70 ms 9192 KB Output is correct
13 Correct 50 ms 9228 KB Output is correct
14 Correct 42 ms 7920 KB Output is correct
15 Correct 96 ms 10524 KB Output is correct
16 Correct 102 ms 10452 KB Output is correct
17 Correct 124 ms 10756 KB Output is correct
18 Correct 108 ms 10848 KB Output is correct
19 Incorrect 45 ms 5776 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2516 KB Output is correct
2 Correct 2 ms 2516 KB Output is correct
3 Correct 97 ms 11496 KB Output is correct
4 Correct 111 ms 11728 KB Output is correct
5 Correct 108 ms 11868 KB Output is correct
6 Correct 95 ms 11580 KB Output is correct
7 Correct 101 ms 11848 KB Output is correct
8 Correct 110 ms 11608 KB Output is correct
9 Correct 105 ms 11712 KB Output is correct
10 Correct 102 ms 11504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2516 KB Output is correct
2 Correct 2 ms 2516 KB Output is correct
3 Correct 2 ms 2516 KB Output is correct
4 Correct 3 ms 2656 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 3 ms 2644 KB Output is correct
7 Correct 3 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Incorrect 1 ms 2644 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2516 KB Output is correct
2 Correct 2 ms 2516 KB Output is correct
3 Correct 2 ms 2516 KB Output is correct
4 Correct 3 ms 2656 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 3 ms 2644 KB Output is correct
7 Correct 3 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 44 ms 7836 KB Output is correct
10 Correct 47 ms 9036 KB Output is correct
11 Correct 45 ms 8856 KB Output is correct
12 Correct 70 ms 9192 KB Output is correct
13 Correct 50 ms 9228 KB Output is correct
14 Correct 42 ms 7920 KB Output is correct
15 Correct 96 ms 10524 KB Output is correct
16 Correct 102 ms 10452 KB Output is correct
17 Correct 124 ms 10756 KB Output is correct
18 Correct 108 ms 10848 KB Output is correct
19 Correct 97 ms 11496 KB Output is correct
20 Correct 111 ms 11728 KB Output is correct
21 Correct 108 ms 11868 KB Output is correct
22 Correct 95 ms 11580 KB Output is correct
23 Correct 101 ms 11848 KB Output is correct
24 Correct 110 ms 11608 KB Output is correct
25 Correct 105 ms 11712 KB Output is correct
26 Correct 102 ms 11504 KB Output is correct
27 Incorrect 2 ms 2644 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -