Submission #966984

# Submission time Handle Problem Language Result Execution time Memory
966984 2024-04-20T19:31:51 Z emad234 Stations (IOI20_stations) C++17
0 / 100
547 ms 952 KB
#include "stations.h"
#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)
{
	pre[u] = ++id;
	for (auto x : gr[u])
	{
		if (x == par)
			continue;
		dfs(x, u);
	}
	post[u] = ++id;
}
void labeling(int u, int par, int d)
{
	if (d % 2)
		labelss[u] = pre[u];
	else
		labelss[u] = post[u];
	for (auto x : gr[u])
	{
		if (x == par)
			continue;
		labeling(x, u, d + 1);
	}
}
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);
	labeling(0, -1, 0);
	return labelss;
}

int find_next_station(int s, int t, std::vector<int> c)
{
	bool pst = 1;
	int root = -1;
	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 > t)
				break;
			else
				id = x;
		}
		if (s < t)
			id = root;
	}
	else
	{
		for (auto x : c)
		{
			if (x > t)
			{
				id = x;
				break;
			}
		}
	}
	return id;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 580 KB Invalid labels (values out of range). scenario=2, k=1000, vertex=0, label=2022
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 572 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=1992
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 331 ms 944 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 547 ms 936 KB Output is correct
2 Incorrect 446 ms 684 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 348 ms 952 KB Wrong query response.
2 Halted 0 ms 0 KB -