Submission #370323

#TimeUsernameProblemLanguageResultExecution timeMemory
370323mjhmjh1104Game (IOI14_game)C++17
100 / 100
529 ms21996 KiB
#include "game.h" #include <tuple> #include <algorithm> using namespace std; int uf[1506], cnt[1506][1506], n; int _find(int x) { if (uf[x] == -1) return x; return uf[x] = _find(uf[x]); } void initialize(int N) { n = N; for (int i = 0; i < n; i++) { uf[i] = -1; for (int j = i + 1; j < n; j++) cnt[i][j] = 1; } } int hasEdge(int u, int v) { u = _find(u), v = _find(v); if (u == v) return 0; tie(u, v) = make_pair(min(u, v), max(u, v)); if (cnt[u][v] > 1) return cnt[u][v]--, 0; for (int i = 0; i < n; i++) if (_find(i) == i && _find(i) != u && _find(i) != v) { auto [ a, b ] = make_pair(min(u, i), max(u, i)); auto [ c, d ] = make_pair(min(v, i), max(v, i)); cnt[a][b] += cnt[c][d]; } uf[v] = u; return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...