Submission #328842

# Submission time Handle Problem Language Result Execution time Memory
328842 2020-11-18T07:58:22 Z dolphingarlic Stations (IOI20_stations) C++14
0 / 100
3000 ms 2097156 KB
#include "stations.h"
#include <vector>
#include <algorithm>

std::vector<int> graph[1000];
bool even[1000];
int tin[1000], tout[1000], timer = 0;

void dfs(int node = 0, int parent = -1, bool even = true) {
	tin[node] = timer++;
	::even[node] = even;
	for (int i : graph[node]) if (i != parent) dfs(i, node, !even);
	tout[node] = timer++;
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	for (int i = 0; i < n - 1; i++) {
		graph[u[i]].push_back(v[i]);
		graph[v[i]].push_back(u[i]);
	}
	dfs();
	std::vector<int> labels(n);
	for (int i = 0; i < n; i++) labels[i] = (even[i] ? tin[i] : tout[i]) / 2;
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
	int mx = *std::max_element(c.begin(), c.end());
	int mn = *std::min_element(c.begin(), c.end());
	if (s < mn) {
		if (t < s || t > mx) return mx;
		return *std::lower_bound(c.begin(), c.end(), t);
	} else {
		if (t > s || t < mn) return mn;
		return *prev(std::upper_bound(c.begin(), c.end(), t));
	}
}
# Verdict Execution time Memory Grader output
1 Runtime error 1585 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3060 ms 492 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1463 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 883 ms 896 KB Output is correct
2 Runtime error 1190 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2376 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -