Submission #1073763

# Submission time Handle Problem Language Result Execution time Memory
1073763 2024-08-24T20:32:52 Z allin27x Stations (IOI20_stations) C++17
0 / 100
482 ms 856 KB
#include <bits/stdc++.h>
using namespace std;
#include "stations.h"

const int N = 1001;
vector<int> adj[N];
int tin[N];
int tout[N];
vector<int> order;

void dfs(int i, int p, int tp) {
	if (!tp) order.push_back(i);
	for (int c: adj[i]) {
		if (c == p) continue;
		dfs(c,i, !tp);
	}
	if (tp) order.push_back(i);
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	for (int i=0; i<n; i++) adj[i].clear();
	std::vector<int> labels(n);
	for (int i=0; i<n-1; i++) {
		adj[u[i]].push_back(v[i]);
		adj[v[i]].push_back(u[i]);
	}
	dfs(0,0,0);
	for (int i=0; i<n; i++) labels[order[i]] = i;
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
	if (s > c[0]) {
		// s is time-out, all neighbors are time-in
		// c[0] is the parent
		int n = c.size();
		vector<int> tout(n);
		for (int i=1; i<n-1; i++) {
			tout[i] = tin[i+1] - 1;
		}
		tout[n-1] = s - 1;
		for (int i=1; i<n; i++) {
			if (c[i] <= t && t<=tout[i]) return c[i];
		}
		return c[0];
	} else {
		// s is time-in, all neighbors are time-out
		// c[n-1] is the parent
		int n = c.size();
		vector<int> tin(n);
		for (int i=n-2; i>0; i--) {
			tin[i] = c[i-1] + 1;
		}
		tin[0] = s + 1;
		for (int i=0; i<n-1; i++) {
			if (tin[i] <= t && t<=c[i]) return c[i];
		}
		return c[n-1];
	}
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 856 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 856 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 482 ms 684 KB Output is correct
2 Incorrect 376 ms 804 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 600 KB Invalid labels (duplicates values). scenario=1, label=0
2 Halted 0 ms 0 KB -