Submission #771480

# Submission time Handle Problem Language Result Execution time Memory
771480 2023-07-03T04:29:33 Z ono_de206 Connecting Supertrees (IOI20_supertrees) C++14
Compilation error
0 ms 0 KB
#include "supertrees.h"
#include<bits/stdc++.h>
using namespace std;

#define in insert
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// #define int long long
 
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

const int mxn = 1010;
int par[mxn];

int get(int x) {
	return (x == par[x] ? x : par[x] = get(par[x]));
}

void unite(int x, int y) {
	x = get; y = get(y);
	if(x == y) return;
	par[y] = x;
}

int construct(vector<vector<int>> p) {
	int n = p.size();
	vector<vector<int>> answer(n, vector<int>(n));
	for(int i = 0; i < n; i++) {
		par[i] = i;
	}
	int mx = 0;
	for (int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			if(p[i][j] > 0) {
				unite(i, j);
				mxx(mx, p[i][j]);
			} 
		}
	}
	if(mx == 0) {
		build(answer);
		return 1;
	}
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			if(p[i][j] == 0 && get(i) == get(j)) {
				return 0;
			}
		}
	}
	vector<int> vis(n);
	for(int i = 0; i < n; i++) {
		if(vis[i]) continue;
		int ls = i;
		for(int j = i + 1; j < n; j++) {
			if(get(j) == get(i)) {
				answer[ls][j] = answer[j][ls] = 1;
			}
		}
	}
	build(answer);
	return 1;
}

Compilation message

supertrees.cpp: In function 'void unite(int, int)':
supertrees.cpp:29:6: error: cannot resolve overloaded function 'get' based on conversion to type 'int'
   29 |  x = get; y = get(y);
      |      ^~~
supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:45:5: error: 'mxx' was not declared in this scope; did you mean 'mx'?
   45 |     mxx(mx, p[i][j]);
      |     ^~~
      |     mx