Submission #48326

#TimeUsernameProblemLanguageResultExecution timeMemory
48326jeongGame (IOI14_game)C++17
15 / 100
3 ms1444 KiB
#include <stdio.h> #define N (1500) int par[N], d[N], rd[N], e[N][N], m[N][N], nn; void initialize(int n){ nn=n; for(int i=0;i<n;i++){ par[i]=i,d[i]=rd[i]=n-1; for(int j=0; j<n;j++)e[i][j]=i!=j,m[i][j]=0; } } int find(int x){if(par[x] == x)return x;return par[x] = find(par[x]);} void f(int x){ if(d[x] != 1)return; for(int i=0; i<nn; i++)if(find(i) == x && rd[i]){ for(int j=0; j<nn; j++)if(e[i][j]){ int y = find(j); d[x]=rd[i]=0;d[y]--;rd[j]--; par[x]=y;m[i][j]=m[j][i]=1;e[i][j]=e[j][i]=0;f(y); break; } break; } } int hasEdge(int u, int v){ int a = find(u), b = find(v); if(m[u][v])return 1; d[a]--;d[b]--; rd[u]--;rd[v]--; e[u][v]=e[v][u]=0; f(a);f(b); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...