# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
759185 | Dan4Life | Game (IOI14_game) | C++17 | 1 ms | 344 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int n, p[1501],sz[1501];
vector<int> v[1501];
bool chk[1501][1501];
int findSet(int i){return i==p[i]?i:p[i]=findSet(p[i]);}
int unionSet(int i, int j){
int x = findSet(i), y = findSet(j);
if(x==y) return 1;
if(sz[x]<sz[y]) swap(x,y);
for(auto u : v[y]) v[x].pb(u); v[y].clear();
p[y] = x; sz[x]+=sz[y]; return 1;
}
void initialize(int N){
n = N; for(int i =0; i < N; i++) p[i]=i,sz[i]=1;
}
int hasEdge(int u, int vv){
int cnt = 0;
int x = findSet(u), y = findSet(vv);
if(x==y){ chk[u][vv]=chk[vv][u]=1; return 0; }
for(auto i : v[x]) for(auto j : v[y]) cnt+=v[i][j];
chk[u][vv]=chk[vv][u]=1;
return cnt==sz[x]*sz[y]-1?unionSet(u,vv):0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |