Submission #197966

# Submission time Handle Problem Language Result Execution time Memory
197966 2020-01-24T12:20:54 Z Minnakhmetov Split the Attractions (IOI19_split) C++14
0 / 100
8 ms 5084 KB
#include "split.h"
#include <bits/stdc++.h>
using namespace std;

const int N = 2e5 + 5;
vector<int> g[N];
bool used[N];

vector<int> solve_for_line(int n, int a, int b, int c) {
	vector<int> res(n, 0);

	int x = 0;
	while (g[x].size() > 1)
		x++;

	vector<int> v;

	while (v.size() < n) {
		used[x] = 1;
		v.push_back(x);

		for (int to : g[x]) {
			if (!used[to]) {
				x = to;
				break;
			}
		}
	}

	for (int i = 0; i < a; i++) {
		res[v[i]] = 1;
	}

	for (int i = a; i < a + b; i++) {
		res[v[i]] = 2;
	}

	for (int i = a + b; i < n; i++) {
		res[v[i]] = 3;
	}

	return res;
}

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

	bool line = true;

	for (int i = 0; i < n; i++) {
		if (g[i].size() > 2) {
			line = false;
			break;
		}
	}

	vector<int> res(n, 0);

	if (line)
		res = solve_for_line(n, a, b, c);

	return res;
}

Compilation message

split.cpp: In function 'std::vector<int> solve_for_line(int, int, int, int)':
split.cpp:18:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while (v.size() < n) {
         ~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4984 KB ok, correct split
2 Incorrect 7 ms 4984 KB jury found a solution, contestant did not
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4984 KB ok, correct split
2 Incorrect 6 ms 4984 KB jury found a solution, contestant did not
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 4984 KB jury found a solution, contestant did not
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 5084 KB jury found a solution, contestant did not
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4984 KB ok, correct split
2 Incorrect 7 ms 4984 KB jury found a solution, contestant did not
3 Halted 0 ms 0 KB -