제출 #586475

#제출 시각아이디문제언어결과실행 시간메모리
586475TekorGame (IOI14_game)C++17
0 / 100
2 ms468 KiB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
#define pii pair <int,int>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
const int N = 2e3 + 100;
int cnt[N][N],sz[N],dsu[N],n;
bool ex[N];
int getroot(int v) {
	return dsu[v] == v ? v : dsu[v] = getroot(dsu[v]);
}
void merg(int v,int u) {
	v = getroot(v);
	u = getroot(u);
	if(v == u)return;
	dsu[u] = v;
	ex[u] = 0;
	for(int j = 0;j < n;j++) {
		if(!ex[j] || j == v)continue;
		cnt[v][j] += cnt[u][j];
		cnt[j][v] += cnt[j][u];
	}
	sz[v] += sz[u];
}
void initialize(int N) {
	n = N;
	for(int i = 0;i < n;i++) {
		dsu[i] = i;
		sz[i] = 1;
		ex[i] = 1;
	}	
}
int hasEdge(int u, int v) {
	u = getroot(u);
	v = getroot(v);
	if(cnt[v][u] + 1 == sz[v] * sz[u]) {
		merg(v,u);
	}else {
		cnt[v][u]++;
		cnt[u][v]++;
	}
}

컴파일 시 표준 에러 (stderr) 메시지

game.cpp: In function 'int hasEdge(int, int)':
game.cpp:46:1: warning: no return statement in function returning non-void [-Wreturn-type]
   46 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...