Submission #1062655

#TimeUsernameProblemLanguageResultExecution timeMemory
1062655damjandavkovGame (IOI14_game)C++17
42 / 100
1071 ms14936 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; vector<set<int> > v; vector<int> pa; vector<bool> w; int N; int dfs(int i) { int s = 1; for (auto h : v[i]) { if (!w[h]) { pa[h] = i; w[h] = 1; s += dfs(h); } } return s; } void initialize(int n) { int i, j; N = n; v.resize(n); pa.resize(n); w.resize(n); vector<int> p(n); for (i = 0; i < n; i++) p[i] = i; random_shuffle(p.begin(), p.end()); for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { if (j != i) v[p[i]].insert(p[j]); } } for (i = 0; i < n; i++) w[i] = 0; w[0] = 1; pa[0] = 0; dfs(0); } int hasEdge(int a, int b) { v[a].erase(b); v[b].erase(a); if (pa[a] != b && pa[b] != a) return 0; int s = 0; s = rand() % N; for (int i = 0; i < N; i++) w[i] = 0; w[s] = 1; pa[s] = s; if (dfs(s) == N) return 0; v[a].insert(b); v[b].insert(a); return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...