Submission #577604

#TimeUsernameProblemLanguageResultExecution timeMemory
577604jack715Game (IOI14_game)C++14
15 / 100
1 ms232 KiB
#include "game.h" #include <bits/stdc++.h> #define ll long long #define pb push_back #define pp pop_back #define mp make_pair #define bb back #define ff first #define ss second using namespace std; vector<vector<int> > cnt; vector<int> par; int n; int find(int a) { if (par[a] == a) return a; return par[a] = find(par[a]); } void merge(int a, int b) { par[b] = a; for (int i = 0; i < n; i++) { if (i == a || i == b) continue; cnt[a][i] += cnt[b][i]; cnt[i][a] += cnt[b][i]; cnt[b][i] = 0, cnt[i][b] = 0; } } void initialize(int N) { n = N; par.resize(n), cnt.resize(n, vector<int>(n)); for (int i = 0; i < n; i++) par[i] = i; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cnt[i][j] = 1; } int hasEdge(int u, int v) { int p1 = par[u], p2 = par[v]; cnt[p1][p2]--; cnt[p2][p1]--; if (cnt[p1][p2] == 0) { merge(p1, p2); return 1; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...