Submission #959066

# Submission time Handle Problem Language Result Execution time Memory
959066 2024-04-07T12:52:17 Z The_Samurai Stations (IOI20_stations) C++17
0 / 100
583 ms 684 KB
#include "stations.h"
#include "bits/stdc++.h"
using namespace std;

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	vector<vector<int>> adj(n);
	vector<bool> vis(n);
	for (int i = 0; i < n - 1; i++) {
		adj[u[i]].emplace_back(v[i]);
		adj[v[i]].emplace_back(u[i]);
	}
	int z = 0;
	vector<int> h(n), tin(n), tout(n), ans(n);
	auto dfs = [&](auto &dfs, int u) -> void {
		tin[u] = tout[u] = z++;
		vis[u] = true;
		for (int v: adj[u]) {
			if (vis[v]) continue;
			h[v] = h[u] + 1;
			dfs(dfs, v);
			tout[u] = tout[v];
		}
	};
	dfs(dfs, 0);
	for (int i = 0; i < n; i++) ans[i] = h[i] % 2 ? tout[i] * 2 + 1 : tin[i] * 2;
	// for (int i = 0; i < n; i++) cout << ans[i] << ' ';
	// cout << endl;
	return ans;
}


int find_next_station(int s, int t, std::vector<int> c) {
	sort(c.begin(), c.end());
	// cout << '\t' << s << ' ' << t << endl;
	// cout << '\t';
	// for (int u: c) cout << u << ' ';
	// cout << endl;
	if (s % 2 == 0) {
		for (int u: c) {
			if (s <= t and t <= u) return u;
		}
		return c.back();
	} else {
		reverse(c.begin(), c.end());
		for (int u: c) {
			if (u == c.back()) return u;
			if (u <= t and t <= s) return u;
		}
	}
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:50:1: warning: control reaches end of non-void function [-Wreturn-type]
   50 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 556 KB Invalid labels (duplicates values). scenario=0, label=19
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 528 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 3 ms 552 KB Invalid labels (duplicates values). scenario=1, label=1727
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 583 ms 684 KB Output is correct
2 Correct 459 ms 684 KB Output is correct
3 Incorrect 0 ms 344 KB Invalid labels (duplicates values). scenario=1, label=7
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 552 KB Invalid labels (duplicates values). scenario=1, label=1995
2 Halted 0 ms 0 KB -