| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 759205 | Dan4Life | Game (IOI14_game) | C++17 | 1 ms | 340 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;
int cnt[1501][1501];
int n, p[1501], sz[1501], vis[1501];
int findSet(int i){return i==p[i]?i:p[i]=findSet(p[i]);}
int unionSet(int x, int y){
if(sz[x]>sz[y]) swap(x,y);
fill(vis,vis+n,0); p[y] = x;
for(int i = 0; i < n; i++){
int z = findSet(i);
if(vis[z]) continue; vis[z]=1;
cnt[z][x] = cnt[x][x]+cnt[y][x];
cnt[x][z] = cnt[x][x]+cnt[y][x];
}
return 1;
}
void initialize(int N){
n = N; fill(sz,sz+n,1);
for(int i = 0; i < n; p[i]=i, i++)
for(int j = 0; j < n; j++) cnt[i][j]=(i!=j);
}
int hasEdge(int u, int v){
int x = findSet(u), y = findSet(v);
return x==y or !cnt[x][y]?0*cnt[x][y]--:unionSet(x,y);
}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... | ||||
