제출 #119364

#제출 시각아이디문제언어결과실행 시간메모리
119364Mamnoon_Siam게임 (IOI14_game)C++17
100 / 100
831 ms25464 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; const int maxn = 1.5e3 + 5; int N; int par[maxn]; int g[maxn][maxn]; int find(int u) { return par[u] == u ? u : par[u] = find(par[u]); } void initialize(int n) { N = n; for(int i = 0; i < N; i++) { par[i] = i; } for(int i = 0; i < N; i++) { for(int j = 0; j < N; j++) { g[i][j] = 1; } } } int hasEdge(int u, int v) { int uu = find(u); int vv = find(v); if(g[uu][vv] == 1) { set<int> st; for(int i = 0; i < N; i++) { st.insert(find(i)); } st.erase(uu); st.erase(vv); for(int i : st) { g[i][uu] += g[i][vv]; g[uu][i] += g[vv][i]; } g[uu][vv]--; g[vv][uu]--; par[vv] = uu; return 1; } else { g[uu][vv]--; g[vv][uu]--; return 0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...