Submission #369835

# Submission time Handle Problem Language Result Execution time Memory
369835 2021-02-22T15:12:24 Z MilosMilutinovic Split the Attractions (IOI19_split) C++14
Compilation error
0 ms 0 KB
#include "split.h"
#include <bits/stdc++.h>
using namespace std;

#define pb push_back

const int mxN=1e5;
vector<int> g[mxN], euler;
bool was[mxN];

void dfs(int u) {
	assert(u>=0&&u<n);
	was[u]=true;
	euler.pb(u);
	for(int i:g[u])
		if(!was[i])
			dfs(i);
}

vector<int> find_split(int n, int a, int b, int c, vector<int> u, vector<int> v) {
	int m=(int)u.size();
	for(int i=0; i<m; ++i)
		g[u[i]].pb(v[i]), g[v[i]].pb(u[i]);
	int root;
	for(int i=0; i<n; ++i)
		if((int)g[i].size()==1)
			root=i;
	dfs(root);
	vector<int> ans(n);
	for(int i:euler) {
		if(a>0)
			ans[i]=1, --a;
		else
			if(b>0)
				ans[i]=2, --b;
			else
				ans[i]=3;
	}
	return ans;
}

/*int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	return 0;
}*/

Compilation message

In file included from /usr/include/c++/9/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:33,
                 from split.cpp:2:
split.cpp: In function 'void dfs(int)':
split.cpp:12:17: error: 'n' was not declared in this scope
   12 |  assert(u>=0&&u<n);
      |                 ^