제출 #930603

#제출 시각아이디문제언어결과실행 시간메모리
930603dimashhh게임 (IOI14_game)C++17
0 / 100
29 ms101212 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2e6 + 12, MOD = 998244353; typedef long long ll; #include "game.h" int _n; //int read_int() { // int x; // assert(scanf("%d", &x) == 1); // return x; //} set<int> g[N]; int p[N]; void initialize(int n) { _n = n; for(int i = 0;i < n;i++){ p[i] = i; } for(int i = 0;i < n;i++){ p[i] = i; for(int j = 0;j < n;j++){ g[i].insert(j); } } } int col[N]; int get(int v){ if(p[v] == v) return v; return p[v] = get(p[v]); } void merge(int a,int b){ a = get(a); b = get(b); p[a] = b; } pair<int,int> blocked; int vis[N],timer = 0,ct = 0; void dfs(int v){ vis[v] = timer; ct++; for(int to:g[v]){ pair<int,int> f = {v,to}; if(f == blocked) continue; if(make_pair(f.second,f.first) == blocked) continue; if(vis[to] == timer) continue; dfs(to); } } int hasEdge(int u, int v) { u = get(u); v = get(v); if (u == v) return 0; if(u > v) swap(u,v); blocked = {u,v}; ++timer; ct = 0; dfs(1); if(ct != _n){ merge(u,v); return 1; } g[v].erase(u); g[u].erase(v); return 0; } //int main() { // int n, u, v; // n = read_int(); // initialize(n); // for (int i = 0; i < n * (n - 1) / 2; i++) { // u = read_int(); // v = read_int(); // if (hasEdge(u, v)) { // puts("1"); // } // else puts("0"); // } // return 0; //}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...