Submission #311999

# Submission time Handle Problem Language Result Execution time Memory
311999 2020-10-12T06:08:45 Z htc001 Stations (IOI20_stations) C++14
0 / 100
867 ms 1048 KB
#include<bits/stdc++.h>
#include "stations.h"
using namespace std;

const int N=1005;
int tme;
vector<int> lab;
vector<int> nei[N];

void dfs(int x,int p,int lv){
	if(lv) lab[x-1]=tme++;
	for(int i=0;i<int(nei[x].size());i++){
		int to=nei[x][i];
		if(to!=p) dfs(to,x,lv^1);
	}
	if(!lv) lab[x-1]=tme++;
}

vector<int> label(int n,int k,vector<int> u,vector<int> v){
	lab.clear();
	lab.resize(n);
	tme=0;
	for(int i=0;i<N;i++) nei[i].clear();
	for(int i=0;i<n-1;i++){
		u[i]++;v[i]++;
//		printf("%d %d\n",u[i],v[i]);
		nei[u[i]].push_back(v[i]);
		nei[v[i]].push_back(u[i]);
	}
	dfs(1,-1,0);
	return lab;
}

int find_next_station(int s,int t,vector<int> c){
	vector<int>::iterator it;
	if(s<c[0]){
		if(t>s){
			it=lower_bound(c.begin(),c.end(),t);
			return *it;
		}else return c[int(c.size())-1];
	}else{
		if(t<s){
			it=upper_bound(c.begin(),c.end(),t);
			it--;
			return *it;
		}else return c[0];
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 540 ms 1024 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 469 ms 1048 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 545 ms 1040 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 867 ms 876 KB Output is correct
2 Correct 648 ms 872 KB Output is correct
3 Incorrect 577 ms 1004 KB Wrong query response.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 532 ms 1024 KB Wrong query response.
2 Halted 0 ms 0 KB -