Submission #542831

# Submission time Handle Problem Language Result Execution time Memory
542831 2022-03-28T07:36:14 Z CasperWong Stations (IOI20_stations) C++17
0 / 100
2386 ms 2097152 KB
#include"stations.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll>vec[1500];
vector<int>lab;
ll tim;
void dfs(ll x,ll p){
	lab[x]=tim++;
	for(auto i:vec[x]) if(i!=p){
		dfs(i,x);
	}
}
vector<int>label(int n,int k,vector<int>u,vector<int>v){
	for(int i=0;i<n-1;i++){
		vec[u[i]].push_back(v[i]);
		vec[v[i]].push_back(u[i]);
	}
	for(int i=0;i<n;i++) lab.push_back(0);
	dfs(0,-1);
	/*cout<<"lab: ";
	for(auto i:lab) cout<<i<<" ";
	cout<<endl;*/
	return lab;
}
int find_next_station(int s,int t,vector<int>c){
	/*cout<<"c: ";
	for(auto i:c) cout<<i<<" ";
	cout<<endl;
	cout<<s<<" "<<t<<endl;*/
	if(s<=t){
		ll len=c.size();
		for(int i=len-1;i>=0;i--) if(c[i]<=t){
			//cout<<"return "<<c[i]<<endl;
			return c[i];
		}
	}else{
		for(auto i:c) if(i>=t){
			//cout<<"return "<<i<<endl;
			return i;
		}
	}
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:43:1: warning: control reaches end of non-void function [-Wreturn-type]
   43 | }
      | ^
# Verdict Execution time Memory Grader output
1 Runtime error 1822 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 336 KB Invalid length of array as the response of 'label'. scenario=1, n=994, len=1990
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1363 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Invalid length of array as the response of 'label'. scenario=1, n=2, len=4
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2386 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -