제출 #1108508

#제출 시각아이디문제언어결과실행 시간메모리
1108508Ariadna게임 (IOI14_game)C++14
100 / 100
268 ms27212 KiB
#include <bits/stdc++.h> #define fi first #define se second using namespace std; int n; vector<int> parent; vector<vector<int>> edges; int ufind(int u) { if (parent[u] == u) return u; return parent[u] = ufind(parent[u]); } void ujoin(int u, int v) { u = ufind(u); v = ufind(v); parent[v] = u; for (int i = 0; i < n; ++i) { if (i == u || i == v) continue; edges[u][i] += edges[v][i]; edges[i][u] = edges[u][i]; } } void initialize(int N) { n = N; edges = vector<vector<int>>(n, vector<int>(n, 1)); parent = vector<int>(n); for (int i = 0; i < n; ++i) { parent[i] = i; edges[i][i] = 0; } } int hasEdge(int u, int v) { u = ufind(u), v = ufind(v); if (u != v) { if (edges[u][v] == 1) { ujoin(u, v); return 1; } } edges[u][v]--; edges[v][u]--; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...