Submission #971411

# Submission time Handle Problem Language Result Execution time Memory
971411 2024-04-28T13:18:04 Z emad234 Stations (IOI20_stations) C++17
0 / 100
573 ms 984 KB
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pii pair<int, int>
using namespace std;
vector<int> labelss, pre, post;
vector<vector<int>> gr;
int id;
void dfs(int u, int par, int d)
{
	pre[u] = ++id;
	if (d % 2 == 0)
		labelss[u] = pre[u];
	for (auto x : gr[u])
	{
		if (x == par)
			continue;
		dfs(x, u, d + 1);
	}
	post[u] = ++id;
	if(d % 2) 
		labelss[u] = post[u];
}
vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v)
{
	gr.clear();
	post.clear();
	pre.clear();
	labelss.clear();
	gr.resize(n + 1);
	labelss.resize(n);
	post.resize(n);
	pre.resize(n);
	for (int i = 0; i < n - 1; i++)
	{
		gr[u[i]].push_back(v[i]);
		gr[v[i]].push_back(u[i]);
	}
	dfs(0, -1, 0);
	return labelss;
}

int find_next_station(int s, int t, std::vector<int> c)
{
	bool pst = 1;
	int root = -1;
	sort(c.begin(), c.end());
	for (auto x : c)
	{
		if (x > s)
			pst = 0;
	}
	for (auto x : c)
	{
		if (pst)
			root == -1 ? root = x : root = min(root, x);
		else
			root = max(x, root);
	}
	int id = root;
	if (pst)
	{
		for (auto x : c)
		{
			if(x == root) continue;
			if (x > t)
				break;
			else
				id = x;
		}
		if (s < t)
			id = root;
	}
	else
	{
		for (auto x : c)
		{
			if (x == root)
				continue;
			if (x > t)
			{
				id = x;
				break;
			}
		}
	}
	return id;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 604 KB Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=2017
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 568 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1023
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 356 ms 980 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 573 ms 940 KB Output is correct
2 Incorrect 431 ms 684 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 349 ms 984 KB Wrong query response.
2 Halted 0 ms 0 KB -