Submission #127312

#TimeUsernameProblemLanguageResultExecution timeMemory
127312nxteruGame (IOI14_game)C++14
0 / 100
2 ms376 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; struct UF{ int n,par[1505],rs[1505]; void ini(int x,int v){ n=x; for(int i=0;i<n;i++){ par[i]=i; if(i==v)rs[i]=0; else rs[i]=1; } } int find(int x){ if(par[x]==x)return x; return par[x]=find(par[x]); } void unit(int v,int u){ v=find(v); u=find(u); rs[v]+=rs[u]; par[u]=v; } }; int n,par[1505]; UF p[1505]; int find(int x){ if(par[x]==x)return x; return par[x]=find(par[x]); } void unit(int v,int u){ v=find(v); u=find(u); for(int i=0;i<n;i++)p[v].rs[i]+=p[u].rs[i]; par[u]=v; } void initialize(int N) { n=N; for(int i=0;i<n;i++)par[i]=i,p[i].ini(n,i); } int hasEdge(int u, int v) { u=find(u); v=find(v); if(u==v)return 1; if(p[u].rs[v]>0)return 0; else{ for(int i=0;i<n;i++)p[i].unit(v,u); unit(v,u); return 1; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...