Submission #577575

#TimeUsernameProblemLanguageResultExecution timeMemory
577575MazaalaiGame (IOI14_game)C++17
15 / 100
2 ms384 KiB
#include "game.h" #include <bits/stdc++.h> #define lb lower_bound #define LINE "------------\n" using namespace std; using PII = pair <int, int>; const int N = 1500; // bool path[N][N]; set <int> vals[N]; int n; int par[N]; void initialize(int _n) { n = _n; for (int i = 0; i < n; i++) for (int j = i+1; j < n; j++) { vals[i].insert(j); vals[j].insert(i); } for (int i = 0; i < n-1; i++) { par[i] = n-1; } } int hasEdge(int u, int v) { // cout << LINE; // cout << u << " " << v << '\n'; // for (int i = 0; i < n-1; i++) cout << i << ": " <<par[i] << '\n'; if (par[u] != v && par[v] != u) { vals[u].erase(v); vals[v].erase(u); return 0; } if (par[v] == u) swap(u, v); bool res = 1; for (auto& el : vals[u]) { if (el != par[u] && par[el] != u) { par[u] = el; vals[u].erase(v); vals[v].erase(u); res = 0; break; } } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...