제출 #587768

#제출 시각아이디문제언어결과실행 시간메모리
587768FatihSolak게임 (IOI14_game)C++17
42 / 100
1094 ms12756 KiB
#include "game.h" #include <bits/stdc++.h> #define N 1505 using namespace std; int par[N]; int out[N]; int n; bool vis[N]; set<int> adj[N]; void dfs(int v){ vis[v] = 1; for(auto u:adj[v]){ if(vis[u])continue; dfs(u); } } int find(int a){ if(a == par[a])return a; return par[a] = find(par[a]); } void initialize(int _n) { n = _n; for(int i = 0;i<n;i++){ for(int j = 0;j<n;j++){ if(i == j)continue; adj[i].insert(j); } par[i] = i; out[i] = n-1; } } int hasEdge(int u, int v) { if(u > v)swap(u,v); adj[u].erase(v); adj[v].erase(u); dfs(0); bool ok = 1; for(int i = 0;i<n;i++){ ok &= vis[i]; vis[i] = 0; } if(ok){ 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...