Submission #779297

#TimeUsernameProblemLanguageResultExecution timeMemory
779297fatemetmhrGame (IOI14_game)C++17
0 / 100
2 ms308 KiB
//  ~ Be Name Khoda ~  //

#include "game.h"
#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops,Ofast")

using namespace std;


typedef long long ll;

#define pb       push_back
#define mp       make_pair
#define all(x)   x.begin(), x.end()
#define fi       first
#define se       second

const int maxn  =  1e6   + 10;
const int maxn5 =  2e3   + 10;
const int maxnt =  1.2e6 + 10;
const int maxn3 =  1e3   + 10;
const int mod   =  1e9   + 7;
const ll  inf   =  1e18;

int n,  par[maxn5], num;

int get_par(int a){return par[a] == -1 ? a : par[a] = get_par(par[a]);}

void initialize(int nn) {
    n = nn;
    memset(par, -1, sizeof par);
    num = n;
}

int hasEdge(int u, int v){
    u = get_par(u);
    v = get_par(v);
    if(u == v)
        return 1;
    if(u != v && num == 2)
        return 0;
    num--;
    par[u] = v;
    return 1;
}






















#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...