Submission #1030933

#TimeUsernameProblemLanguageResultExecution timeMemory
1030933tolbiGame (IOI14_game)C++17
100 / 100
368 ms25232 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++){ int h = say[u][i]; say[u][i]-=h; say[u][find(i)]+=h+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...