제출 #897216

#제출 시각아이디문제언어결과실행 시간메모리
897216aqxa게임 (IOI14_game)C++17
0 / 100
1 ms4544 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 1505; int a[N][N], cnt[N][N]; int n; vector<int> e; int get(int x) { return e[x] < 0 ? x : e[x] = get(e[x]); } bool unite(int x, int y) { x = get(x); y = get(y); if (x == y) return false; if (e[x] > e[y]) swap(x, y); e[x] += e[y]; e[y] = x; return true; } void initialize(int _n) { n = _n; e = vector<int>(n, -1); for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { a[i][j] = -1; cnt[i][j] = 1; } } } int hasEdge(int u, int v) { u--; v--; if (u > v) swap(u, v); int cu = get(u), cv = get(v); if (cu == cv) return 1; if (cu > cv) swap(cu, cv); if (cnt[cu][cv] == 1) { unite(cu, cv); int np = get(cu); for (int i = 0; i < n; ++i) { if (e[i] < 0 && i != cu && i != cv) { cnt[min(i, np)][max(i, np)] = cnt[min(i, cu)][max(i, cu)] + cnt[min(i, cv)][max(i, cv)]; } } return 1; } else { cnt[cu][cv]--; return 0; } } // int32_t main() { // ios::sync_with_stdio(false); // cin.tie(nullptr); // return 0; // }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...