답안 #777860

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
777860 2023-07-09T19:24:12 Z t6twotwo 자매 도시 (APIO20_swap) C++17
37 / 100
2000 ms 12104 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), cnt(N), t(N), deg(N);
    auto unite = [&](int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) {
            cnt[x]++;
            return;
        }
        if (sz[x] > sz[y]) {
            swap(x, y);
        }
        p[x] = y;
        t[y] |= t[x];
        sz[y] += sz[x];
        cnt[y] += cnt[x] + 1;
    };
    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]] || cnt[p[X]] >= sz[p[X]]) {
                return z;
            }
        }
    }
    return -1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 33 ms 3788 KB Output is correct
10 Correct 51 ms 4428 KB Output is correct
11 Correct 62 ms 4376 KB Output is correct
12 Correct 57 ms 4624 KB Output is correct
13 Correct 52 ms 4580 KB Output is correct
14 Execution timed out 2089 ms 3924 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Execution timed out 2066 ms 6740 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 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 308 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 340 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 340 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 2 ms 440 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 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 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 33 ms 3788 KB Output is correct
11 Correct 51 ms 4428 KB Output is correct
12 Correct 62 ms 4376 KB Output is correct
13 Correct 57 ms 4624 KB Output is correct
14 Correct 52 ms 4580 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 308 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 340 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
29 Correct 1 ms 340 KB Output is correct
30 Correct 2 ms 440 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 340 KB Output is correct
34 Correct 5 ms 1172 KB Output is correct
35 Correct 57 ms 6428 KB Output is correct
36 Correct 59 ms 6444 KB Output is correct
37 Correct 56 ms 6428 KB Output is correct
38 Correct 55 ms 6296 KB Output is correct
39 Correct 54 ms 6204 KB Output is correct
40 Correct 52 ms 5808 KB Output is correct
41 Correct 57 ms 6700 KB Output is correct
42 Correct 56 ms 6420 KB Output is correct
43 Correct 42 ms 6416 KB Output is correct
44 Correct 59 ms 6748 KB Output is correct
45 Correct 67 ms 10068 KB Output is correct
46 Correct 57 ms 6432 KB Output is correct
47 Correct 58 ms 6420 KB Output is correct
48 Correct 53 ms 6840 KB Output is correct
49 Correct 46 ms 9944 KB Output is correct
50 Correct 37 ms 7072 KB Output is correct
51 Correct 60 ms 7592 KB Output is correct
52 Correct 75 ms 10612 KB Output is correct
53 Correct 75 ms 11420 KB Output is correct
54 Correct 85 ms 12104 KB Output is correct
55 Correct 46 ms 6436 KB Output is correct
56 Correct 85 ms 11072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 33 ms 3788 KB Output is correct
10 Correct 51 ms 4428 KB Output is correct
11 Correct 62 ms 4376 KB Output is correct
12 Correct 57 ms 4624 KB Output is correct
13 Correct 52 ms 4580 KB Output is correct
14 Execution timed out 2089 ms 3924 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 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 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 33 ms 3788 KB Output is correct
11 Correct 51 ms 4428 KB Output is correct
12 Correct 62 ms 4376 KB Output is correct
13 Correct 57 ms 4624 KB Output is correct
14 Correct 52 ms 4580 KB Output is correct
15 Execution timed out 2089 ms 3924 KB Time limit exceeded
16 Halted 0 ms 0 KB -