제출 #280180

#제출 시각아이디문제언어결과실행 시간메모리
280180SamAnd게임 (IOI14_game)C++17
100 / 100
620 ms25336 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; #define m_p make_pair #define fi first #define se second #define all(x) (x).begin(),(x).end() #define sz(x) ((int)(x).size()) typedef long long ll; const int N = 1503; int n; int p[N]; int q[N][N]; int fi(int x) { if (x == p[x]) return x; return p[x] = fi(p[x]); } void initialize(int n) { ::n = n; for (int i = 1; i <= n; ++i) p[i] = i; for (int x = 1; x <= n; ++x) { for (int y = 1; y <= n; ++y) { if (x == y) continue; q[x][y] = 1; } } } int hasEdge(int x, int y) { ++x; ++y; x = fi(x); y = fi(y); if (x == y) return 0; --q[x][y]; --q[y][x]; if (q[x][y]) return 0; p[x] = y; for (int i = 1; i <= n; ++i) { q[y][i] += q[x][i]; q[i][y] += q[x][i]; q[x][i] = 0; q[i][x] = 0; } return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...