Submission #48347

#TimeUsernameProblemLanguageResultExecution timeMemory
48347jeongGame (IOI14_game)C++17
0 / 100
1080 ms544 KiB
#include <stdio.h> #define N (1500) int p[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++){ p[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(p[x] == x)return x;return p[x] = find(p[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[y]--;rd[j]--;d[x]=rd[i]=0; p[x]=y; m[i][j]=m[j][i]=1; if(m[i][j] || m[j][i])while(1); e[i][j]=e[j][i]=0; f(y); break; } break; } } int hasEdge(int u, int v){ if(m[u][v])return 1; else if(e[u][v]==0)return 0; int a=find(u), b=find(v); 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...