제출 #674824

#제출 시각아이디문제언어결과실행 시간메모리
674824bashkort게임 (IOI14_game)C++17
100 / 100
349 ms25180 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; constexpr int N = 1500; int p[N], e[N][N], n; int leader(int x) { while (x != p[x]) x = p[x] = p[p[x]]; return x; } bool unite(int x, int y) { x = leader(x), y = leader(y); if (x == y || e[x][y] > 1) { if (x != y) { e[x][y] -= 1; e[y][x] -= 1; } return false; } p[y] = x; for (int to = 0; to < n; ++to) { if (to != x) { e[x][to] += e[y][to]; e[to][x] += e[to][y]; } } return true; } void initialize(int n) { ::n = n; iota(p, p + n, 0); for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { e[i][j] = e[j][i] = 1; } } } int hasEdge(int u, int v) { return unite(u, v); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...