Submission #1051809

#TimeUsernameProblemLanguageResultExecution timeMemory
1051809TobSplit the Attractions (IOI19_split)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

#include "split.h"

#define F first
#define S second

using namespace std;

typedef long long ll;

const int N = 1e5 + 7;

int n;
int siz[N];
bool bio[N];
vector <int> no;
vector <int> adj[N];

int ldfs(int x) {
	bio[x] = 1;
	no.push_back(x);
	for (auto y : adj[x]) {
		if (bio[y]) continue;
		ldfs(y);
	}
}

vector<int> find_split(int n, int a, int b, int c, vector<int> u, vector<int> v) {
	n = a+b+c;
	vector <int> res(n, 0);
	for (int i = 0; i < n-1; i++) {
		adj[p[i]].push_back(q[i]);
		adj[q[i]].push_back(p[i]);
	}
	int mxdeg = 0;
	for (int i = 0; i < n; i++) mxdeg = max(mxdeg, (int)adj[i].size());
	if (mxdeg <= 2) {
		ldfs(0);
		for (int i = a; i < a+b; i++) res[no[i]] = 1;
		for (int i = a+b; i < n; i++) res[no[i]] = 2;
		return res;
	}
	if (a == 1) {
		ldfs(0);
		for (int i = 0; i < b; i++) res[no[i]] = 1;
		for (int i = b; i < n-1; i++) res[no[i]] = 2;
		return res;
	}
	return 0;
}

Compilation message (stderr)

split.cpp: In function 'int ldfs(int)':
split.cpp:27:1: warning: no return statement in function returning non-void [-Wreturn-type]
   27 | }
      | ^
split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:33:7: error: 'p' was not declared in this scope
   33 |   adj[p[i]].push_back(q[i]);
      |       ^
split.cpp:33:23: error: 'q' was not declared in this scope
   33 |   adj[p[i]].push_back(q[i]);
      |                       ^
split.cpp:50:9: error: could not convert '0' from 'int' to 'std::vector<int>'
   50 |  return 0;
      |         ^
      |         |
      |         int