Submission #941057

# Submission time Handle Problem Language Result Execution time Memory
941057 2024-03-08T06:05:00 Z emad234 Stations (IOI20_stations) C++17
0 / 100
1 ms 536 KB
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pii pair<int,int>
using namespace std;
vector<int> labelss,pre,post;
vector<vector<int>>gr;
int id;
void dfs(int u,int par){
	pre[u] = ++id;
	for(auto x : gr[u]){
		if(x == par) continue;
		dfs(x,u);
	}
	post[u] = ++id;
}
void labeling(int u,int par,int d){
	if(d % 2) labelss[u] = pre[u];
	else labelss[u] = post[u];
	cout<<labelss[u]<<' ';
	for(auto x : gr[u]){
		if(x == par) continue;
		labeling(x,u,d + 1);
	}
}
vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	gr.clear();
	post.clear();
	pre.clear();
	labelss.clear();
	gr.resize(n + 1);
	labelss.resize(n);
	post.resize(n);
	pre.resize(n);
	for(int i = 0;i < n - 1;i++){
		gr[u[i]].push_back(v[i]);
		gr[v[i]].push_back(u[i]);
	}
	dfs(0,-1);
	labeling(0,-1,0);
	cout<<'\n';
	return labelss;
}

int find_next_station(int s, int t, std::vector<int> c) {
	bool pst = 1;
	int root = -1;
	for(auto x : c) {
		if(x > s) pst = 0;
	}
	for(auto x : c){
		if(pst) root == -1 ? root = x : root = min(root,x);
		else  root = max(x,root);
	}
	int id = root;
	if(pst){
		for(auto x :  c){
			if(x > t) break;
			else id = x;
		}
		if(s < t) id = root;
	}else{
		for(auto x : c){
			if(x > t){
				id = x;
				break;
			}
		}
	}
	return id;
}

# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 440 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 536 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 440 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 440 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 436 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -