Submission #577615

#TimeUsernameProblemLanguageResultExecution timeMemory
577615jack715Game (IOI14_game)C++14
100 / 100
391 ms25256 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++) { 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++) { if (i == j) cnt[i][j] = 0; else cnt[i][j] = 1; } } int hasEdge(int u, int v) { int p1 = find(u), p2 = find(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...