Submission #1055079

# Submission time Handle Problem Language Result Execution time Memory
1055079 2024-08-12T14:30:15 Z Gromp15 Stations (IOI20_stations) C++17
0 / 100
507 ms 8620 KB
#include <bits/stdc++.h>
#include "stations.h"
using namespace std;

bool line = 1;

const int N = 1000;
vector<vector<int>> go(N, vector<int>(N, -1));
bool init = 0;

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	vector<vector<int>> adj(N);
	/*
	for (int i = 0; i < N-1; i++) {
		if (u[i] > v[i]) swap(u[i], v[i]);
		binary &= (v[i] + 1) / 2 == (u[i] + 1);
		adj[u[i]].push_back(v[i]);
		adj[v[i]].push_back(u[i]);
	}
	*/
	if (!init) {
		init = 1;
		for (int i = 2; i <= N; i++) {
			int u = i - 1, v = i / 2 - 1;
			adj[u].emplace_back(v);
			adj[v].emplace_back(u);
		}
		for (int i = 0; i < N; i++) {
			auto dfs = [&](auto&& s, int v) -> void {
				for (int u : adj[v]) if (u != go[i][v]) {
					go[i][u] = v;
					s(s, u);
				}
			};
			dfs(dfs, i);
		}
	}
	vector<int> ans(n);
	iota(ans.begin(), ans.end(), 0);
	return ans;
	/*
	int r = -1;
	for (int i = 0; i < n; i++) {
		if (adj[i].size() == 1) r = i;
		line &= adj[i].size() <= 2;
	}
	if (line) {
		vector<int> ans(n);
		int t = 0;
		auto dfs = [&](auto&& s, int v, int p) -> void {
			ans[v] = t++;
			for (int u : adj[v]) if (u != p) s(s, u, v);
		};
		dfs(dfs, r, -1);
		return ans;
	}
	*/
	/*
	vector<int> tin(n), tout(n);
	int timer = 0;
	auto dfs = [&](auto&& s, int v, int p) -> void {
		tin[v] = timer++;
		for (int u : adj[v]) if (u != p) {
			s(s, u, v);
		}
		tout[v] = timer - 1;
	};
	dfs(dfs, 0, -1);
	vector<int> ans(n);
	for (int i = 0; i < n; i++) ans[i] = tin[i] * 1000 + tout[i];
	return ans;
	*/
}

bool anc(int x, int y) {
	int tins = x / 1000, touts = x % 1000;
	int tint = y / 1000, toutt = y % 1000;
	return tins <= tint && toutt <= touts;
}

int find_next_station(int s, int t, std::vector<int> c) {
	/*
	if (line) {
		for (int x : c) if ((x-s)*(x-t) <= 0) return x;
	}
	*/
	return go[t][s];
	/*
	if (anc(s, t)) {
		for (int x : c) {
			if (anc(s, x) && anc(x, t)) return x;
		}
	}
	else {
		for (int x : c) {
			if (anc(x, s)) return x;
		}
	}
	*/
	assert(0);
}
# Verdict Execution time Memory Grader output
1 Incorrect 319 ms 8620 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 296 ms 8620 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 334 ms 8620 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 507 ms 8620 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 294 ms 8620 KB Wrong query response.
2 Halted 0 ms 0 KB -