Submission #1089272

# Submission time Handle Problem Language Result Execution time Memory
1089272 2024-09-16T08:55:50 Z T0p_ Stations (IOI20_stations) C++14
0 / 100
585 ms 684 KB
#include "stations.h"
#include <bits/stdc++.h>

using namespace std;

const int N = 1000;

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

void dfs(int u, int p, int l) {
	lbl[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) {
	lbl = 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;
		}
	}

	for (int i=0 ; i<n ; i++) {
		degree[i] = 0;
		g[i].clear();
	}

	return lbl;
}

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 Incorrect 375 ms 684 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Invalid labels (duplicates values). scenario=0, label=10
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 331 ms 684 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 585 ms 684 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 351 ms 684 KB Wrong query response.
2 Halted 0 ms 0 KB -