Submission #831424

#TimeUsernameProblemLanguageResultExecution timeMemory
831424mousebeaverGame (IOI14_game)C++14
42 / 100
1089 ms1492 KiB
#include <bits/stdc++.h> #include "game.h" using namespace std; vector<vector<int>> adjmatrix(0); void initialize(int n) { adjmatrix.assign(n, vector<int> (n, -1)); for(int i = 0; i < n; i++) { adjmatrix[i][i] = 0; } } void dfs(int i, vector<vector<int>>& adjmatrix, vector<bool>& visited) { visited[i] = true; for(int j = 0; j < (int) adjmatrix[i].size(); j++) { if(!visited[j] && adjmatrix[i][j] != 0) { dfs(j, adjmatrix, visited); } } } int hasEdge(int u, int v) { int n = adjmatrix.size(); adjmatrix[u][v] = 0; adjmatrix[v][u] = 0; vector<bool> visited(n, false); dfs(0, adjmatrix, visited); if(find(visited.begin(), visited.end(), false) != visited.end()) { adjmatrix[u][v] = 1; adjmatrix[v][u] = 1; return 1; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...