Submission #876018

#TimeUsernameProblemLanguageResultExecution timeMemory
876018Darren0724Game (IOI14_game)C++17
100 / 100
264 ms22348 KiB
#include "game.h" //#include "grader.cpp" #include <bits/stdc++.h> using namespace std; const int N=1500; int c[N][N]; int pa[N]; int Find(int k){ if(pa[k]==k){ return k; } return pa[k]=Find(pa[k]); } void onion(int a,int b){ pa[b]=a; for(int i=0;i<N;i++){ if(i==Find(i)){ c[a][i]+=c[b][i]; c[i][a]=c[a][i]; } } } void initialize(int n) { for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(i!=j)c[i][j]=1; } pa[i]=i; } } int hasEdge(int u, int v) { if(u>v)swap(u,v); u=Find(u); v=Find(v); c[u][v]--; c[v][u]--; if(!c[u][v]){ onion(u,v); return 1; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...