답안 #380111

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
380111 2021-03-20T10:13:09 Z Theo830 게임 (IOI14_game) C++17
0 / 100
164 ms 262148 KB
    #include "game.h"
    #include <bits/stdc++.h>
    using namespace std;
    typedef int ll;
    typedef pair<ll,ll> ii;
    #define iii pair<ll,ii>
    #define f(i,a,b) for(int i = a;i < b;i++)
    #define pb push_back
    #define vll vector<ll>
    #define F first
    #define S second
    #define all(x) (x).begin(), (x).end()
    ///I hope I will get uprating and don't make mistakes
    ///I will never stop programming
    ///sqrt(-1) Love C++
    ///Please don't hack me
    ///@TheofanisOrfanou Theo830
    ///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst)
    ///Stay Calm
    ///Look for special cases
    ///Beware of overflow and array bounds
    ///Think the problem backwards
    ///Training
    ll siz[1505] = {0};
    ll par[1505];
    ll N;
    ll find_par(ll x){
        if(par[x] == x){
            return x;
        }
        return par[x] = find_par(x);
    }
    void enose(ll x,ll y){
        ll p1 = find_par(x);
        ll p2 = find_par(y);
        par[p2] = p1;
        siz[p1] += siz[p2];
        siz[p2] = 0;
    }
    void initialize(int n){
        f(i,0,n+5){
            siz[i] = 1;
            par[i] = i;
        }
        N = n;
    }
    int hasEdge(int u, int v){
        if(u > v){
            swap(u,v);
        }
        ll p1 = find_par(u);
        ll p2 = find_par(v);
        if(find_par(p1) == find_par(p2)){
            return 1;
        }
        if(siz[p1] + siz[p2] <= N/2){
            enose(u,v);
            return 1;
        }
        return 0;
    }
# 결과 실행 시간 메모리 Grader output
1 Runtime error 163 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 161 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 164 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -