답안 #828133

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
828133 2023-08-17T05:37:00 Z SUNWOOOOOOOO 자매 도시 (APIO20_swap) C++17
0 / 100
2000 ms 6588 KB
// #include "swap.h"
#include <bits/stdc++.h>
using namespace std;
using tint = array <int, 3>;
const int mxN = 200005;
int n, m, deg[mxN];
tint edge[mxN];

struct dsu {
    tint G[mxN]; // node, is cycle, is deg3
    void init(){
        for (int i = 0; i < n; i++) G[i] = {i, 0, 0};
    }
    int find(int x){
        if (G[x][0] != x) G[x][0] = find(G[x][0]);
        return G[x][0];
    }
    void uni(int x, int y){
        x = find(x), y = find(y);
        if (x != y){
            G[y][0] = x;
            G[x][1] += G[y][1];
            G[x][2] += G[y][2];
        }
        else {
            G[x][1] = 1;
        }
    }
} dsu;

void init(int N, int M, vector<int> U, vector<int> V, vector<int> W) {
    n = N, m = M;
    for (int i = 0; i < m; i++) edge[i] = {W[i], U[i], V[i]};
    sort(edge, edge + m);
}

int getMinimumFuelCapacity(int X, int Y) {
    dsu.init();
    memset(deg, 0, sizeof deg);

    for (int i = 0; i < m; i++){
        if (++deg[edge[i][1]] >= 3) dsu.G[edge[i][1]][2] = 1;
        if (++deg[edge[i][2]] >= 3) dsu.G[edge[i][2]][2] = 1;
        dsu.uni(edge[i][1], edge[i][2]);

        X = dsu.find(X), Y = dsu.find(Y);
        if (X == Y && (dsu.G[X][1] || dsu.G[X][2])){
            return edge[i][0];
        }
    }
    return -1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 28 ms 3836 KB Output is correct
10 Correct 37 ms 4408 KB Output is correct
11 Correct 48 ms 4408 KB Output is correct
12 Correct 42 ms 4588 KB Output is correct
13 Correct 44 ms 4900 KB Output is correct
14 Execution timed out 2094 ms 4016 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Execution timed out 2071 ms 6588 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 980 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Incorrect 1 ms 1108 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 980 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 28 ms 3836 KB Output is correct
11 Correct 37 ms 4408 KB Output is correct
12 Correct 48 ms 4408 KB Output is correct
13 Correct 42 ms 4588 KB Output is correct
14 Correct 44 ms 4900 KB Output is correct
15 Correct 1 ms 1108 KB Output is correct
16 Incorrect 1 ms 1108 KB Output isn't correct
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 28 ms 3836 KB Output is correct
10 Correct 37 ms 4408 KB Output is correct
11 Correct 48 ms 4408 KB Output is correct
12 Correct 42 ms 4588 KB Output is correct
13 Correct 44 ms 4900 KB Output is correct
14 Execution timed out 2094 ms 4016 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 980 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 28 ms 3836 KB Output is correct
11 Correct 37 ms 4408 KB Output is correct
12 Correct 48 ms 4408 KB Output is correct
13 Correct 42 ms 4588 KB Output is correct
14 Correct 44 ms 4900 KB Output is correct
15 Execution timed out 2094 ms 4016 KB Time limit exceeded
16 Halted 0 ms 0 KB -