제출 #778811

#제출 시각아이디문제언어결과실행 시간메모리
778811jakobrs게임 (IOI14_game)C++17
0 / 100
2 ms468 KiB
#include <cstdint> #include <vector> #include "game.h" #include <iostream> 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) { u -= 1; v -= 1; 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...