Submission #1030927

#TimeUsernameProblemLanguageResultExecution timeMemory
1030927tolbiGame (IOI14_game)C++17
15 / 100
4 ms9308 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; int par[1500],sz[1500],say[1500][1500]; int find(int node){ if (par[node]==node) return node; return par[node]=find(par[node]); } int n; void initialize(int n) { ::n=n; iota(par,par+n,0); fill(sz,sz+n,1); memset(say,0,sizeof(say)); } int hasEdge(int u, int v) { if (find(u)==find(v)) return 0; u=find(u); v=find(v); if (say[u][v]!=sz[u]*sz[v]-1 && say[v][u]!=sz[u]*sz[v]-1){ say[u][v]++,say[v][u]++; return 0; } //mergelemeye karar verdiysem if (sz[u]<sz[v]) swap(u,v); for (int i = 0; i < n; i++){ say[u][find(i)]+=say[v][i]; } sz[u]+=sz[v]; sz[v]=0; par[v]=u; return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...