답안 #892751

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
892751 2023-12-25T20:53:58 Z raul2008487 게임 (IOI14_game) C++17
0 / 100
1 ms 344 KB
#include<bits/stdc++.h>
#define ll long long
#define vl vector<ll>
#include "game.h"
using namespace std;
const int sz = 1505;
struct DSU{
    vl e, ne;
    void init(ll n){
        e.assign(n+1, -1);
        ne.assign(n+1, 0);
    }
    ll base(ll x){
        if(e[x] < 0){
            return x;
        }
        return e[x] = base(e[x]);
    }
    bool unite(ll x, ll y){
        x = base(x);
        y = base(y);
        /*if(x == y){
            ll fe = (e[x] * (e[x] + 1) / 2);
            ne[x]++;
            if(ne[x] == fe){
                as = 1;
            }
            return as;
        }
        if(e[x] == -1 && e[y] == -1){as = 1;}*/
        if(e[x] > e[y]){
            swap(x, y);
        }
        if(x != y){e[x] += e[y];e[y] = x;}
        ll fe = (e[x] * (e[x] + 1) / 2);
        ne[x]++;
        if(x != y){ne[x] += ne[y], ne[y] = 0;}
        return ne[x] == fe;
    }
};
DSU dsu;
void initialize(int n) {
    dsu.init(n);
}
int hasEdge(int u, int v) {
    return dsu.unite(u, v);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -