Submission #1155082

#TimeUsernameProblemLanguageResultExecution timeMemory
1155082alexddGame (IOI14_game)C++20
100 / 100
247 ms9324 KiB
#include "game.h" #include<bits/stdc++.h> using namespace std; int cntcomp; int father[1505]; vector<int> comp[1505]; bool asked[1505][1505]; void initialize(int n) { for(int i=0;i<n;i++) { father[i] = i; comp[i].push_back(i); } cntcomp=n; } void unite(int u, int v) { u = father[u]; v = father[v]; if((int)comp[v].size() > (int)comp[u].size()) swap(u,v); vector<int> aux = comp[v]; comp[v].clear(); for(int x:aux) { comp[u].push_back(x); father[x]=u; } cntcomp--; } int hasEdge(int u, int v) { asked[u][v] = asked[v][u] = 1; if(father[u]==father[v]) return 1; u = father[u]; v = father[v]; bool bun=1; for(int x:comp[u]) { for(int y:comp[v]) { if(!asked[x][y]) { bun=0; break; } } if(!bun) break; } if(bun) { unite(u,v); return 1; } else return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...