제출 #831417

#제출 시각아이디문제언어결과실행 시간메모리
831417mousebeaver게임 (IOI14_game)C++14
42 / 100
1087 ms3464 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>>& adjlist, vector<bool>& visited) { visited[i] = true; for(int j : adjlist[i]) { if(!visited[j]) { dfs(j, adjlist, visited); } } } int hasEdge(int u, int v) { int n = adjmatrix.size(); vector<vector<int>> adjlist(n, vector<int> (0)); for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if(adjmatrix[i][j] == 1 || ((min(i, j) != min(u, v) || max(i, j) != max(u, v)) && adjmatrix[i][j] == -1)) { adjlist[i].push_back(j); } } } vector<bool> visited(n, false); dfs(0, adjlist, visited); if(find(visited.begin(), visited.end(), false) != visited.end()) { adjmatrix[u][v] = 1; adjmatrix[v][u] = 1; return 1; } adjmatrix[u][v] = 0; adjmatrix[v][u] = 0; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...