제출 #1290283

#제출 시각아이디문제언어결과실행 시간메모리
1290283hssaan_arifGame (IOI14_game)C++20
42 / 100
1096 ms17760 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(pa == pr )return;
    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;
    for (int i=0 ; i<m ; i++){
        P[i] = i;
        L[i] = {i};
    }
}

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