Submission #783873

#TimeUsernameProblemLanguageResultExecution timeMemory
783873FatihSolakGame (IOI14_game)C++17
42 / 100
1083 ms11320 KiB
#include "game.h" #include <bits/stdc++.h> #define N 1500 using namespace std; int par[N]; int cnt[N][N]; int find(int a){ if(a == par[a])return a; return par[a] = find(par[a]); } int n; void initialize(int n){ ::n = n; for(int i = 0;i<n;i++){ par[i] = i; for(int j = 0;j<n;j++){ cnt[i][j] = i != j; } } } int hasEdge(int u, int v){ int tot = 0; for(int i = 0;i<n;i++){ if(find(i) == find(v)){ tot += cnt[find(u)][i]; } } cnt[find(u)][v]--; cnt[find(v)][u]--; if(tot > 1){ return 0; } for(int i = 0;i<n;i++){ cnt[find(u)][i] += cnt[find(v)][i]; } par[find(v)] = find(u); return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...