제출 #70346

#제출 시각아이디문제언어결과실행 시간메모리
70346Angelos게임 (IOI14_game)C++11
0 / 100
3 ms616 KiB
//#include "grader.h" #include "game.h" #include <bits/stdc++.h> #define MAXN 1010 int R[MAXN] , S[MAXN][MAXN] , sz[MAXN] , dis[MAXN] , N; using namespace std; void initialize(int n) { memset(dis , 0 , sizeof dis); N = n; for(int i=0; i<n; i++) R[i] = i , sz[i] = 1; for(int i=0; i<n; i++) for(int j=0; j<n; j++) S[i][j] = (i != j) ? 1 : 0; } int fat(int x){ if(R[x] == x) return x; R[x] = fat(R[x]); return R[x]; } void unionn(int a , int b){ int A = fat(a) , B = fat(b); if(sz[B] > sz[A]) swap(A , B); if(sz[A] >= sz[B]) { for(int i=0; i<N; i++) if(i != A && i != B && !dis[i]) S[A][i] += S[B][i]; sz[A] += sz[B]; dis[B] = 1; R[B] = A; } } int hasEdge(int u, int v){ int U = fat(u) , V = fat(v); if(U == V || S[U][V] > 1) { S[U][V] --; return 0; } unionn(u , v); return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...