제출 #369134

#제출 시각아이디문제언어결과실행 시간메모리
369134Pulgster게임 (IOI14_game)C++17
0 / 100
1 ms364 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " #define ed <<endl; struct unionFind{ vector<int> par; vector<int> av; vector<int> rnk; void init(int n){ par.resize(n); av.resize(n); rnk.resize(n); for(int i=0;i<n;i++){ par[i] =i; rnk[i]=0; av[i]=n-1; } }; int find(int p){ if(par[p] != p){ par[p] = find(par[p]); } return par[p]; } void join(int u, int v){ int ur = find(u); int vr = find(v); if(ur == vr){ return; } if(rnk[vr] > rnk[ur]) swap(ur, vr); if(rnk[ur] == rnk[vr]) rnk[ur]++; par[vr] = ur; av[ur] += av[vr]; } }; unionFind uf; void initialize(int n) { uf.init(n); } int hasEdge(int u, int v) { int ur = uf.find(u); int vr = uf.find(v); if(ur == vr){ uf.av[ur] -= 2; return 1; } int mn = min(uf.av[ur], uf.av[vr]); if(mn == 1){ uf.join(u, v); uf.av[uf.find(u)] -= 2; return 1; }else{ uf.av[uf.find(u)]--; uf.av[uf.find(v)]--; return 0; } // return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...