Submission #168188

#TimeUsernameProblemLanguageResultExecution timeMemory
168188johuthaGame (IOI14_game)C++14
42 / 100
1077 ms516 KiB
#include "game.h" #include <vector> #include <iostream> using namespace std; struct graph { int n; vector<vector<bool>> adjmatrix; vector<int> visited; void dfs(int curr) { if (visited[curr]) return; visited[curr] = true; for (int i = 0; i < n; i++) { if (i == curr || !adjmatrix[curr][i]) continue; dfs(i); } } bool shouldadd(int a, int b) { adjmatrix[a][b] = false; adjmatrix[b][a] = false; visited.assign(n, false); visited[a] = 0; dfs(a); bool all = true; for (int i = 0; i < n; i++) { if (!visited[i]) all = false; } if (!all) { adjmatrix[a][b] = true; adjmatrix[b][a] = true; } return !all; } }; graph g; void initialize(int n) { g.n = n; g.adjmatrix.resize(n, vector<bool>(n, true)); g.visited.resize(n, false); } int hasEdge(int u, int v) { return g.shouldadd(u, v); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...