#include "game.h"
#include <bits/stdc++.h>
using namespace std;
const int y=1500;
int rt[y], ik, k=0;
struct DSU
{
vector<int> t, p;
DSU(int n)
{
t.assign(n, 1); p.resize(n); iota(p.begin(), p.end(), 0);
}
int find(int x)
{
if(x==p[x])return x; return p[x]=find(p[x]);
}
bool uni(int x, int y)
{
int a=find(x), b=find(y); if(a==b)return true; if(t[a]<t[b]) swap(a, b);
t[a]+=t[b]; p[b]=a;
}
};
DSU r(1500);
void initialize(int n) {
/*for(int i=0; i<n; i++){if(i%2==0)rt[i]=0; else rt[i]=1;} */ik=n;
}
int hasEdge(int u, int v) {
//if(r.find(u)!=r.find(v)&&(r.t[u]==0||r.t[v]==0)){ r.uni(u, v); return 0;}
if(k==ik-2)return 0; r.uni(u, v); k++; return 1;
}
Compilation message (stderr)
game.cpp: In member function 'bool DSU::uni(int, int)':
game.cpp:20:25: warning: control reaches end of non-void function [-Wreturn-type]
20 | t[a]+=t[b]; p[b]=a;
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |