제출 #778814

#제출 시각아이디문제언어결과실행 시간메모리
778814jakobrs게임 (IOI14_game)C++17
42 / 100
1086 ms2720 KiB
#include <cstdint> #include <vector> #include "game.h" using i64 = int64_t; const i64 MAXN = 1500; i64 N; bool adj[MAXN][MAXN]; void initialize(int n) { N = n; for (i64 i = 0; i < N; i++) { for (i64 j = 0; j < N; j++) { if (i != j) adj[i][j] = true; } } } bool connected(int u, int v) { std::vector<int> stack; std::vector<bool> visited(N, false); stack.push_back(u); while (!stack.empty()) { int i = stack.back(); stack.pop_back(); if (visited[i]) { continue; } visited[i] = true; if (i == v) return true; for (int j = 0; j < N; j++) { if (adj[i][j] && !visited[j]) { stack.push_back(j); } } } return false; } int hasEdge(int u, int v) { adj[u][v] = false; adj[v][u] = false; if (connected(u, v)) { return false; } else { adj[u][v] = true; adj[v][u] = true; return true; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...