Submission #432426

# Submission time Handle Problem Language Result Execution time Memory
432426 2021-06-18T09:35:54 Z Pbezz Stations (IOI20_stations) C++14
0 / 100
925 ms 696 KB
#include "stations.h"
#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
typedef pair<ll,ll> pii;

const ll MAXN = 1005;
const ll INF = 1e9+7;
vector<vector<ll>>adj(MAXN);
int deg[MAXN],order[MAXN];

void dfs(int node, int p,int mark){
order[node]=mark;
for(auto u:adj[node]){
if(u==p)continue;

dfs(u,node,mark+1);

}
}


std::vector<int> label(int n, int k,std::vector<int>u,std::vector<int>v){
	std::vector<int> labels(n);
	int i;

	for(i=0;i<n;i++) {
	deg[i]=0;
	adj[i].clear();
	order[i]=0;
	}


	for(i=0;i<n-1;i++){
	adj[u[i]].pb(v[i]);
	adj[v[i]].pb(u[i]);
	deg[u[i]]++;
	deg[v[i]]++;
	}

	for(i=0;i<n;i++) {
	if(deg[i]>2)break;
	}

	if(i!=n){
	int cur=1000;
	for(auto u:adj[i]){
	dfs(u,i,cur);
	cur+=1000;
	}
	order[i]=0;


	}else{

	for(i=0;i<n;i++) {
	if(deg[i]==1)break;
	}

	dfs(i,-1,0);
	}
	for (i = 0; i < n; i++) {
		labels[i] = order[i];
	//cout<<order[i]<<" ";
	}//cout<<endl;
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {

	if(s==0){
	int ans=t/1000;
	return 1000*ans;
	}

	int mini=INF,maxi=-1,tt=t/1000,ss=s/1000;
	for(auto u:c){
	mini=min(mini,u);
	maxi=max(maxi,u);
	}

	if(tt==ss&&t>s)return maxi;

	return mini;
}
# Verdict Execution time Memory Grader output
1 Incorrect 493 ms 612 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 320 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=2, label=1001
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 537 ms 512 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 925 ms 496 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 527 ms 696 KB Wrong query response.
2 Halted 0 ms 0 KB -