Submission #1364102

#TimeUsernameProblemLanguageResultExecution timeMemory
1364102retardeStations (IOI20_stations)C++20
8 / 100
287 ms444 KiB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;

int timer = -1;
void dfs(int node, int prev, vector<vector<int>> &adj, vector<int> &tin, vector<int> &tout) {
	tin[node] = ++timer;
	for (auto &neighbour : adj[node]) {
		if (neighbour == prev) continue;
		dfs(neighbour, node, adj, tin, tout);
	}
	tout[node] = timer;
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	vector<int> ans(n); for (int i = 0; i < n; i++) ans[i] = i;
	return ans;
}

bool dfs(int node, int prev, int src, vector<vector<int>> &adj, int targ) {
	if (node == targ) return true;
	bool h = false;
	for (auto &neighbour : adj[node]) {
		if (neighbour == prev) continue;
		if (neighbour == src) continue;
		h |= dfs(neighbour, node, src, adj, targ);
	}
	return h;
}

const int N = 1001;
int sb(int x, int y) {
	vector<int> tmp; tmp.push_back(x);
	while (tmp.back() <= y) {
		tmp.push_back(tmp.back()*2+1);
	}
	tmp.pop_back();
	int l = tmp.back();
	int r = l + (1 << ((int)tmp.size() - 1)) - 1;
	return (y <= r);
}

int find_next_station(int s, int t, std::vector<int> c) {
	for (auto &neighbour : c) {
		if (neighbour == (s-1)/2) continue;
		if (sb(neighbour, t)) return neighbour;
	}
	return (s-1)/2;
}
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...