Submission #1089267

# Submission time Handle Problem Language Result Execution time Memory
1089267 2024-09-16T08:52:24 Z T0p_ Stations (IOI20_stations) C++14
0 / 100
3000 ms 2097152 KB
#include "stations.h"
#include <bits/stdc++.h>

using namespace std;

const int N = 1000;

int degree[N];
vector<int> g[N], labels;

void dfs(int u, int p, int l) {
	labels[u] = l;

	for (int v : g[u]) {
		if (v == p) {
			continue;
		}

		dfs(v, u, l+1);
	}
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	labels = vector<int>(n);

	for (int i=0 ; i<n-1 ; i++) {
		g[u[i]].push_back(v[i]);
		g[v[i]].push_back(u[i]);

		degree[u[i]]++;
		degree[v[i]]++;
	}

	for (int i=0 ; i<n ; i++) {
		if (degree[i] == 1) {
			dfs(i, -1, 0);
			break;
		}
	}

	return labels;
}

int find_next_station(int s, int t, vector<int> c) {
	return s < t ? c[1] : c[0];
}
# Verdict Execution time Memory Grader output
1 Runtime error 1776 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3059 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1739 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Invalid labels (duplicates values). scenario=1, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3090 ms 2097152 KB Time limit exceeded
2 Halted 0 ms 0 KB -