# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
399051 | Bill_00 | Game (IOI14_game) | C++14 | 1 ms | 332 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 "game.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
int a[1505][1505],p[1505],sz[1505];
bool flag[1505][1505];
vector<int>vec[1505];
int find(int node){
if(node==p[node]) return node;
else return p[node]=find(p[node]);
}
void initialize(int n) {
for(int i=1;i<=n;i++){
p[i]=i;
sz[i]=1;
}
}
int hasEdge(int u, int v) {
u++;
v++;
u=find(u);
v=find(v);
if(a[u][v]+1==sz[u]*sz[v]){
if(sz[u]<sz[v]){
swap(u,v);
}
for(int y=0;y<vec[v].size();y++){
a[u][v]+=a[v][vec[v][y]];
a[v][u]+=a[vec[v][y]][v];
if(flag[u][vec[v][y]]==0){
vec[u].pb(vec[v][y]);
flag[u][vec[v][y]]=1;
}
if(flag[vec[v][y]][u]==0){
vec[vec[v][y]].pb(u);
flag[vec[v][y]][u]=1;
}
}
sz[u]+=sz[v];
u=p[v];
return 1;
}
else{
if(flag[u][v]==0){
vec[u].pb(v);
flag[u][v]=1;
}
if(flag[v][u]==0){
vec[v].pb(u);
flag[v][u]=1;
}
a[u][v]++;
a[v][u]++;
return 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... |