Submission #1290277

#TimeUsernameProblemLanguageResultExecution timeMemory
1290277hssaan_arifGame (IOI14_game)C++20
0 / 100
1 ms340 KiB
#include <bits/stdc++.h>
#include "game.h"
using namespace std;

#define endl "\n"
#define pb push_back
// #define int long long
#define fi first
#define se second

const int N = 1505, Mod = 1e9 + 7, LG = 20;

int n , P[N];
vector<int> L[N];
map<pair<int,int> , bool> M;

int find(int a){
    if (P[a] == a) return a;
    return P[a] = find(P[a]);
}

void join(int a , int b){
    int pa = find(a);
    int pr = find(b);
    if (L[pa].size() < L[pr].size()){
        P[pa] = pr;
        int sz = L[pa].size();
        while(sz--){
            L[pr].pb(L[pa].back());
            L[pa].pop_back();
        }
    }else{
        P[pr] = pa;
        int sz = L[pr].size();
        while(sz--){
            L[pa].pb(L[pr].back());
            L[pr].pop_back();
        }
    }
}

void initialize(int m) {
    n = m;
}

int hasEdge(int u, int v) {
    M[{u,v}] = 1;
    for (int i : L[find(u)]){
        for (int j : L[find(v)]){
            if (!M[{i,j}]) return 0;
        }
    }
    join(u,v);
    return 1;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...