Submission #735749

#TimeUsernameProblemLanguageResultExecution timeMemory
735749vjudge1Game (IOI14_game)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>

using namespace std;

struct DSU{
	vector<int> v;
	void init(int n){v.assign(n, -1);}
	int get(int x){return v[x] < 0 ? x : v[x] = get(v[x]);}
	int unite(int x, int y){
		x = get(x); y = get(y);
		if(x == y) return 0;
		deg[x][y]++; deg[y][x]++;
		if(deg[x][y] != v[x] * v[y]) return 0;
		if(v[x] > v[y]) swap(x, y);
		v[x] += v[y]; v[y] = x;
		for(int i = 0; i < (int)v.size(); i++){
			if(v[i] < 0){
				deg[i][x] += deg[i][y];
				deg[x][i] += deg[y][i];
			}
		}
		return 1;
	}
};

DSU UF;

void initialize(int n){
	UF.init(n);
}

int hasEdge(int u, int v){
	return UF.unite(u, v);
}

Compilation message (stderr)

game.cpp: In member function 'int DSU::unite(int, int)':
game.cpp:12:3: error: 'deg' was not declared in this scope
   12 |   deg[x][y]++; deg[y][x]++;
      |   ^~~