제출 #56511

#제출 시각아이디문제언어결과실행 시간메모리
56511aome게임 (IOI14_game)C++17
100 / 100
768 ms160328 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; const int N = 1505; int n; int par[N]; int cnt[N][N]; int find(int u) { return u == par[u] ? u : par[u] = find(par[u]); } void initialize(int _n) { n = _n; for (int i = 0; i < n; ++i) { for (int j = 0; j < i; ++j) { cnt[i][j] = cnt[j][i] = 1; } } for (int i = 0; i < n; ++i) par[i] = i; } int hasEdge(int u, int v) { u = find(u), v = find(v); if (u == v || cnt[u][v] > 1) { cnt[u][v]--, cnt[v][u]--; return 0; } cnt[u][v] = cnt[v][u] = 0; for (int i = 0; i < n; ++i) { cnt[v][i] += cnt[u][i], cnt[u][i] = 0; cnt[i][v] += cnt[i][u], cnt[i][u] = 0; } par[u] = v; return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...