Submission #677594

#TimeUsernameProblemLanguageResultExecution timeMemory
677594ThegeekKnight16Game (IOI14_game)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> #include "game.h" using namespace std; vector<set<int> > grafo; vector<int> pai; vector<int> prof; int quantF = 2; int find(int v) { if (v == pai[v]) return v; return pai[v] = find(pai[v]); } void une(int a, int b) { a = find(a); b = find(b); if (a == b) return; if (prof[a] < prof[b]) swap(a, b); pai[b] = a; prof[a] = max(prof[a], prof[b] + 1); } void initialize(int n) { grafo.resize(n+1); pai.resize(n+1); prof.resize(n+1); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) if (i != j) grafo[i].insert(j); pai[i] = i; prof[i] = 1; } } int hasEdge(int u, int v) { for (auto x = grafo[u].begin(); x != grafo[u].end();) { if (pai[*x] != *x) x = grafo[u].erase(x); else x++; } for (auto x = grafo[v].begin(); x != grafo[v].end();) { if (pai[*x] != *x) x = grafo[v].erase(x); else x++; } if (grafo[u].find(v) == grafo[u].end() || grafo[v].find(u) == grafo[v].end()) { grafo[u].erase(v); grafo[v].erase(u); return 0; } if ((grafo[u].size() == 2 xor grafo[v].size() == 2) && quantF) { grafo[u].erase(v); grafo[v].erase(u); quantF--; return 0; } else if (grafo[u].size() <= 2 || grafo[v].size() <= 2) { grafo[u].erase(v); grafo[v].erase(u); une(u, v); return 1; } else { grafo[u].erase(v); grafo[v].erase(u); return 0; } }

Compilation message (stderr)

game.cpp: In function 'int hasEdge(int, int)':
game.cpp:57:26: warning: suggest parentheses around comparison in operand of '^' [-Wparentheses]
   57 |     if ((grafo[u].size() == 2 xor grafo[v].size() == 2) && quantF)
      |          ~~~~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...