Submission #228474

#TimeUsernameProblemLanguageResultExecution timeMemory
228474bharat2002Game (IOI14_game)C++14
0 / 100
5 ms384 KiB
#include<bits/stdc++.h> #include "game.h" using namespace std; const int N=1510; int deg[N][N], p[N], srank[N]; int n; void initialize(int NC) { n=NC; for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) deg[i][j]=0; srank[i]=1;p[i]=i; } } int find(int x) { if(p[x]!=x) p[x]=find(p[x]); return p[x]; } void UNION(int a, int b) { if(srank[a]<srank[b]) swap(a, b); srank[a]+=srank[b];p[b]=a; for(int i=1;i<=n;i++) deg[a][i]+=deg[b][i]; } int hasEdge(int u, int v) { int tu=find(u), tv=find(v); int tot=srank[tu]*srank[tv];deg[tu][tv]++;deg[tv][tu]++; if(deg[tu][tv]==tot) { UNION(tu, tv);return 1; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...