답안 #381620

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
381620 2021-03-25T11:13:30 Z ritul_kr_singh 게임 (IOI14_game) C++17
컴파일 오류
0 ms 0 KB
#include "game.h"
#include "bits/stdc++.h"
using namespace std;

vector<int> e;
int find(int u){
	return e[u] < 0 ? u : e[u] = find(e[u]);
}
int sz(int u){
	return -e[find(u)];
}
void union(int u, int v){
	u = find(u), v = find(v);
	if(u==v) return;
	if(e[u] > e[v]) swap(u, v);
	e[u] += e[v], e[v] = u;
}


void initialize(int n){
	e.assign(n+1, -1);
}

int hasEdge(int u, int v){
	if(find(u)==find(v) or sz(u)+sz(v)<n){
		union(u, v);
		return 1;
	}
	return 0;
}

Compilation message

game.cpp:12:11: error: expected identifier before '(' token
   12 | void union(int u, int v){
      |           ^
game.cpp:12:12: error: expected unqualified-id before 'int'
   12 | void union(int u, int v){
      |            ^~~
game.cpp:12:12: error: expected ')' before 'int'
   12 | void union(int u, int v){
      |           ~^~~
      |            )
game.cpp: In function 'int hasEdge(int, int)':
game.cpp:25:37: error: 'n' was not declared in this scope
   25 |  if(find(u)==find(v) or sz(u)+sz(v)<n){
      |                                     ^
game.cpp:26:3: error: expected primary-expression before 'union'
   26 |   union(u, v);
      |   ^~~~~