Submission #1271992

#TimeUsernameProblemLanguageResultExecution timeMemory
1271992thuhienneGame (IOI14_game)C++20
Compilation error
0 ms0 KiB
#include "game.h"

int root[1509],size[1509],edge[1509][1509],n;
//root i: dsu bth
//edge i j: da co bao nhieu canh duoc hoi giua 2 tplt co i lam root va j lam root

void initialize(int _n) {
	n = _n;
	for (int i = 1;i <= n;i++) root[i] = i,size[i] = 1;
}

int hasEdge(int u, int v) {
	int ru = getroot(u),rv = getroot(v);
	
	edge[ru][rv]++;edge[rv][ru]++;
	
	if (edge[ru][rv] == size[ru] * size[rv]) {
		return 1;
		root[ru] = rv;
		for (int i = 1;i <= n;i++) {
			edge[i][rv] += edge[i][ru];
			edge[rv][i] += edge[ru][i];
		}
	} else return 0;
}

Compilation message (stderr)

game.cpp: In function 'int hasEdge(int, int)':
game.cpp:13:18: error: 'getroot' was not declared in this scope; did you mean 'root'?
   13 |         int ru = getroot(u),rv = getroot(v);
      |                  ^~~~~~~
      |                  root
game.cpp:15:18: error: 'rv' was not declared in this scope; did you mean 'ru'?
   15 |         edge[ru][rv]++;edge[rv][ru]++;
      |                  ^~
      |                  ru
game.cpp:25:1: warning: control reaches end of non-void function [-Wreturn-type]
   25 | }
      | ^