Submission #236310

#TimeUsernameProblemLanguageResultExecution timeMemory
236310crossing0verGame (IOI14_game)C++17
100 / 100
485 ms17016 KiB
#include<bits/stdc++.h> #include "game.h" using namespace std; int A[1500][1500],sz[1500],P[1500]; int par (int a) { return a == P[a] ? a : P[a] = par (P[a]); } int join(int a,int b) { int x = par(a); int y = par(b); if (x == y) return 0; if (A[x][y] != 1) { A[x][y]--;A[y][x]--;return 0;} if (sz[x] < sz[y]) swap(x,y); for (int i = 0; i < 1500; i++) if (i != x && i != y) { int t = A[x][i] + A[y][i]; A[x][i] = A[i][x] = t; } P[y] = x; sz[x] += sz[y]; return 1; } void initialize(int n) { for (int i = 0; i < n; i++) { sz[i] = 1; P[i] = i; for (int j = 0;j < n; j++) { if (i != j) A[i][j] = 1; } } } int hasEdge(int u, int v) { return join(u,v); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...