Submission #979305

# Submission time Handle Problem Language Result Execution time Memory
979305 2024-05-10T14:10:15 Z fv3 Stations (IOI20_stations) C++14
0 / 100
3000 ms 2097152 KB
#include <bits/stdc++.h>
#include "stations.h"

using namespace std;

vector<int> lbl;
vector<vector<int>> adj;

void DFS(int index, int last, int id)
{
	lbl[index] = id;
	for (auto node : adj[index])
	{
		if (node == last) continue;
		DFS(node, index, id + 1);
	}
}

vector<int> label(int N, int K, vector<int> U, vector<int> V)
{
	adj.resize(N, {});
	lbl.resize(N, 0);

	for (int i = 0; i < N - 1; i++)
	{
		adj[U[i]].push_back(V[i]);
		adj[V[i]].push_back(U[i]);
	}

	for (int i = 0; i < N; i++)
	{
		if (adj[i].size() == 1)
		{
			DFS(i, -1, 0);
			break;
		}
	}
	return lbl;
}

int find_next_station(int S, int T, vector<int> C)
{
	return ((T > S) ? S + 1 : S - 1);
}
# Verdict Execution time Memory Grader output
1 Runtime error 2389 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3047 ms 572 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1359 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 593 ms 684 KB Output is correct
2 Incorrect 428 ms 684 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2138 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -