Submission #1049348

#TimeUsernameProblemLanguageResultExecution timeMemory
1049348ArthuroWichGame (IOI14_game)C++17
0 / 100
1 ms512 KiB
#include "game.h" #include<bits/stdc++.h> using namespace std; int p[1505]; set<pair<int, int>> st[1505]; int find(int x) { if (p[x] == x) { return x; } p[x] = find(p[x]); return p[x]; } void merge(int a, int b) { a = find(a); b = find(b); if (a == b) { return; } p[b] = a; } void initialize(int n) { for (int i = 0; i < n; i++) { p[i] = i; } for (int i = 0; i < n; i++) { for (int j = i+1; j < n; j++) { st[i].insert({i, j}); st[j].insert({i, j}); } } } int hasEdge(int u, int v) { int a = u, b = v; u = min(a, b); v = max(a, b); if (st[u].size() < 2 || st[v].size() < 2) { st[u].erase({u, v}); st[v].erase({u, v}); merge(u, v); return 1; } st[u].erase({u, v}); st[v].erase({u, v}); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...