Submission #427721

# Submission time Handle Problem Language Result Execution time Memory
427721 2021-06-14T19:58:40 Z AugustinasJucas Stations (IOI20_stations) C++14
0 / 100
936 ms 700 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
const int dydis = 1000;
vector<int> gr[dydis];
int enter[dydis];
int leave[dydis];
vector<int> ret (dydis);
int dbInd = 0;
void dfs(int v, int came, int h = 0){
	enter[v] = dbInd++;
	for(auto x : gr[v]){
		if(x == came) continue;
		dfs(x, v, h+1);
	}
	leave[v] = dbInd++;
	if(h & 1){
		ret[v] = leave[v];
	}else{
		ret[v] = enter[v];
	}
}
vector<int> compress(vector<int> a){
	vector<int> ret;
	auto cp = a;
	sort(cp.begin(), cp.end());
	for(auto x : a){
		ret.push_back(lower_bound(cp.begin(), cp.end(), x) - cp.begin());
	}
	return ret;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	for(int i = 0; i < n; i++){
		gr[i].clear();
	}
	dbInd = 0;
	ret.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);
	ret = compress(ret);
	return ret;
}

int find_next_station(int s, int t, vector<int> c) {
	return c[0];
	bool yraMaz = 1;
	for(auto x : c){
		if(x < s) yraMaz = 0;
	}
	if(yraMaz){
		int dd = c.back();
		int last = s;
		for(auto x : c){
			if(x == dd && s != 0) continue;
			int enter = last+1;
			int leave = x;
			if(enter <= t && t <= leave) return x;
			last = leave;
		}
		return c.back();
	}else{ 
		//cout << "jis yra leave" << endl;
		for(int i = 1; i < (int)c.size(); i++){
			int enter = c[i];
			int leave = (i == (int)c.size() - 1 ? s - 1 : c[i+1] - 1);
			if(enter <= t && t <= leave){
				return c[i];
			}
		}
		return c[0];
	}
	
}

# Verdict Execution time Memory Grader output
1 Incorrect 608 ms 648 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 483 ms 700 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 601 ms 668 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 936 ms 400 KB Output is correct
2 Incorrect 812 ms 524 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 617 ms 656 KB Wrong query response.
2 Halted 0 ms 0 KB -