제출 #372467

#제출 시각아이디문제언어결과실행 시간메모리
372467idk321게임 (IOI14_game)C++11
42 / 100
1091 ms12780 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; const int N = 1500; set<int> adj[N]; bool vis[N]; int n; void dfs(int node, int par) { vis[node] = true; for (int next : adj[node]) { if (!vis[next]) dfs(next, node); } } void initialize(int n1) { n = n1; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { adj[i].insert(j); adj[j].insert(i); } } } int hasEdge(int u, int v) { adj[u].erase(v); adj[v].erase(u); for (int i = 0; i < n; i++) { vis[i] = false; } dfs(0, -1); bool bridge = false; for (int i = 0; i < n; i++) { if (!vis[i]) bridge = true; } if (!bridge) return 0; adj[u].insert(v); adj[v].insert(u); return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...