Submission #117447

#TimeUsernameProblemLanguageResultExecution timeMemory
117447dragonslayeritGame (IOI14_game)C++14
100 / 100
454 ms20560 KiB
#include "game.h" #include <cassert> #include <cstdio> int conn[1505][1505]; int component[1505]; int N; void initialize(int n) { N=n; for(int i=0;i<n;i++){ component[i]=i; } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ conn[i][j]=(i!=j); } } } void connect(int a,int b){ for(int i=0;i<N;i++){ conn[i][a]+=conn[i][b]; conn[i][b]=0; conn[a][i]+=conn[b][i]; conn[b][i]=0; } for(int i=0;i<N;i++){ if(component[i]==b){ component[i]=a; } } } int hasEdge(int u, int v) { int a=component[u],b=component[v]; assert(a!=b); conn[a][b]--; conn[b][a]--; if(conn[a][b]==0){ connect(a,b); return 1; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...