Submission #804611

#TimeUsernameProblemLanguageResultExecution timeMemory
804611farukSplit the Attractions (IOI19_split)C++17
0 / 100
792 ms1048576 KiB
#include "split.h"
#include <bits/stdc++.h>
#define mp make_pair
#define all(a) a.begin(), a.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

vector<vector<int> > graph;
int n;

vector<int> vec;
void dfs(int curr, int par) {
	vec.push_back(curr);
	for (int nei : graph[curr])
		if (nei != par)
			dfs(nei, curr);
}

vector<int> get_order() {
	int s = 0;
	for (int i = 0; i < n; i++)
		if (graph[i].size() == 1)
			s = i;
	dfs(s, -1);
	return vec;
}

vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
	vector<int> res(n);
	::n = n;
	graph.resize(n);
	for (int i = 0; i < p.size(); i++)
	{
		graph[p[i]].push_back(q[i]);
		graph[q[i]].push_back(p[i]);
	}

	vector<int> order = get_order();
	for (int i = 0; i < a; i++)
		res[order[i]] = 1;
	for (int i = a; i < a+b; i++)
		res[order[i]] = 2;
	for (int i = a+b; i < a+b+c; i++)
		res[order[i]] = 3;
	
	return res;
}

Compilation message (stderr)

split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:35:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |  for (int i = 0; i < p.size(); i++)
      |                  ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...