답안 #777880

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
777880 2023-07-09T20:46:03 Z t6twotwo 자매 도시 (APIO20_swap) C++17
37 / 100
2000 ms 8816 KB
#include "swap.h"
#include <bits/stdc++.h>
using namespace std;
int N;
vector<tuple<int, int, int>> edges;
constexpr int inf = 2e9;
void init(int n, int M, vector<int> U, vector<int> V, vector<int> W) {
    N = n;
    for (int i = 0; i < M; i++) {
        edges.emplace_back(W[i], U[i], V[i]);
    }
    sort(edges.begin(), edges.end());
}
int getMinimumFuelCapacity(int X, int Y) {
    vector<int> p(N);
    iota(p.begin(), p.end(), 0);
    function<int(int)> find = [&](int x) {
        return x == p[x] ? x : p[x] = find(p[x]);
    };
    vector<int> sz(N, 1), t(N), deg(N);
    auto unite = [&](int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) {
            t[x] = 1;
            return;
        }
        if (sz[x] > sz[y]) {
            swap(x, y);
        }
        p[x] = y;
        t[y] |= t[x];
        sz[y] += sz[x];
    };
    for (auto [z, x, y] : edges) {
        if (++deg[x] == 3) {
            t[find(x)] = 1;
        }
        if (++deg[y] == 3) {
            t[find(y)] = 1;
        }
        unite(x, y);
        if (find(X) == find(Y)) {
            if (t[p[X]]) {
                return z;
            }
        }
    }
    return -1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 33 ms 4672 KB Output is correct
10 Correct 51 ms 5444 KB Output is correct
11 Correct 55 ms 5360 KB Output is correct
12 Correct 58 ms 5504 KB Output is correct
13 Correct 53 ms 5484 KB Output is correct
14 Execution timed out 2055 ms 5088 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Execution timed out 2008 ms 7788 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 308 KB Output is correct
14 Correct 1 ms 312 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 308 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 33 ms 4672 KB Output is correct
11 Correct 51 ms 5444 KB Output is correct
12 Correct 55 ms 5360 KB Output is correct
13 Correct 58 ms 5504 KB Output is correct
14 Correct 53 ms 5484 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 316 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 308 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 308 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 5 ms 1144 KB Output is correct
35 Correct 58 ms 4960 KB Output is correct
36 Correct 59 ms 4932 KB Output is correct
37 Correct 57 ms 4944 KB Output is correct
38 Correct 56 ms 4932 KB Output is correct
39 Correct 54 ms 4924 KB Output is correct
40 Correct 52 ms 4676 KB Output is correct
41 Correct 57 ms 4944 KB Output is correct
42 Correct 57 ms 4932 KB Output is correct
43 Correct 43 ms 4932 KB Output is correct
44 Correct 59 ms 4936 KB Output is correct
45 Correct 66 ms 7556 KB Output is correct
46 Correct 57 ms 5000 KB Output is correct
47 Correct 54 ms 4932 KB Output is correct
48 Correct 58 ms 5168 KB Output is correct
49 Correct 47 ms 7804 KB Output is correct
50 Correct 37 ms 5416 KB Output is correct
51 Correct 53 ms 5664 KB Output is correct
52 Correct 74 ms 7948 KB Output is correct
53 Correct 79 ms 8420 KB Output is correct
54 Correct 91 ms 8816 KB Output is correct
55 Correct 46 ms 4928 KB Output is correct
56 Correct 83 ms 8216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 33 ms 4672 KB Output is correct
10 Correct 51 ms 5444 KB Output is correct
11 Correct 55 ms 5360 KB Output is correct
12 Correct 58 ms 5504 KB Output is correct
13 Correct 53 ms 5484 KB Output is correct
14 Execution timed out 2055 ms 5088 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 33 ms 4672 KB Output is correct
11 Correct 51 ms 5444 KB Output is correct
12 Correct 55 ms 5360 KB Output is correct
13 Correct 58 ms 5504 KB Output is correct
14 Correct 53 ms 5484 KB Output is correct
15 Execution timed out 2055 ms 5088 KB Time limit exceeded
16 Halted 0 ms 0 KB -