제출 #236306

#제출 시각아이디문제언어결과실행 시간메모리
236306crossing0ver게임 (IOI14_game)C++17
0 / 100
8 ms6400 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]--;return 0;}
	if (sz[x] < sz[y]) swap(x,y);
	for (int i = 0; i < 1500; i++) {
		if (i != x && i != y) A[x][i] = A[i][x] = A[x][i] + A[y][i];
	}
	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...