제출 #835166

#제출 시각아이디문제언어결과실행 시간메모리
835166gustason게임 (IOI14_game)C++14
0 / 100
0 ms212 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; constexpr int nax = 81; int N; set<int> adj[nax]; set<int> curr[nax]; bool vis[nax]; int cnt = 0; void reset() { for(int i = 0; i < N; i++) { vis[i] = false; } cnt = 0; } void dfs(int v, bool all_y) { vis[v] = true; cnt++; for(int u : curr[v]) { if (!vis[u]) { dfs(u, all_y); } } if (all_y) { for(int u : adj[v]) { if (!vis[u]) { dfs(u, all_y); } } } } bool dfs() { reset(); dfs(0, false); if (cnt == N) { return false; } reset(); dfs(0, true); if (cnt != N) { return false; } return true; } void initialize(int n) { N = n; // curr + all Yes -> form full // curr + all No -> not form full 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) { if (u > v) { swap(u, v); } adj[u].erase(v); adj[v].erase(u); curr[u].insert(v); curr[v].insert(u); if (!dfs()) { curr[u].erase(v); curr[v].erase(u); return 0; } return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...