Submission #23700

#TimeUsernameProblemLanguageResultExecution timeMemory
23700HiasatGame (IOI14_game)C++14
100 / 100
846 ms26596 KiB
#include "game.h" #include <iostream> #include <cstdio> #include <set> #include <vector> #include <assert.h> #include <memory.h> using namespace std; typedef pair<int,int> pii; int dsu[2010],N; int f[2010][2010]; int find(int u){ return dsu[u] == u ? u : dsu[u] = find(dsu[u]); } void initialize(int n) { N = n; for (int i = 0; i < n; ++i){ dsu[i] = i; for(int j = 0 ; j < n ; j++){ if(i == j) continue; f[i][j] = 1; } } } int hasEdge(int u, int v) { f[find(u)][find(v)]--; f[find(v)][find(u)]--; if(!f[find(u)][find(v)]){ int a = find(u); int b = find(v); for(int i = 0 ; i < N ; i++){ f[a][i] += f[b][i]; f[i][a] = f[a][i]; } dsu[b] = a; return true; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...