Submission #314822

# Submission time Handle Problem Language Result Execution time Memory
314822 2020-10-21T11:24:57 Z kostia244 Stations (IOI20_stations) C++17
0 / 100
876 ms 644 KB
#include "stations.h"
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
using namespace std;
namespace lab {
vector<vector<int>> g;
vector<int> tin, tout, d;
int timer;
void dfs(int v, int p) {
	tin[v] = ++timer;
	for(auto &i : g[v]) if(i != p) {
		d[i] = d[v]+1;
		dfs(i, v);
	}
	tout[v] = timer;
}
};
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	using namespace lab;
	timer = -1;
	tin = tout = d = vector<int>(n);
	g.assign(n, vector<int>());
	for(int i = 0; i+1 < n; i++) {
		g[u[i]].push_back(v[i]);
		g[v[i]].push_back(u[i]);
	}
	dfs(0, 0);
	std::vector<int> labels(n);
	for (int i = 0; i < n; i++) {
		labels[i] = (d[i]&1) ? 1 + 2*tout[i] : 2*tin[i];
	}
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
	int type = s&1, par;
	if(s) {
		if(type == 0) {//tin here, tout in neighbors
			par = *max_element(all(c));
			c.erase(max_element(all(c)));
		} else {//tout here
			par = *min_element(all(c));
			c.erase(min_element(all(c)));
		}
	} else par = -1;
	if(!type) {
		if((t/2) < (s/2)) return par;
		int mn = 1<<30;
		for(auto &i : c) if((t/2) <= (i/2)) mn = min(mn, i);
		if(mn == 1<<30) mn = par;
		return mn;
	}
	if(t > s) return par;
	int mx = -1;
	for(auto &i : c) if((t/2) >= (i/2)) mx = max(mx, i);
	if(mx == -1) mx = par;
	return mx;
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 512 KB Invalid labels (duplicates values). scenario=0, label=19
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 492 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 4 ms 512 KB Invalid labels (duplicates values). scenario=1, label=1727
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 876 ms 640 KB Output is correct
2 Correct 655 ms 644 KB Output is correct
3 Incorrect 1 ms 256 KB Invalid labels (duplicates values). scenario=1, label=7
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 504 KB Invalid labels (duplicates values). scenario=1, label=1995
2 Halted 0 ms 0 KB -