Submission #509968

# Submission time Handle Problem Language Result Execution time Memory
509968 2022-01-14T12:58:04 Z jamezzz Stations (IOI20_stations) C++17
0 / 100
3000 ms 496 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;

#define pb push_back

vector<int> l,AL[1005];
int deg[1005];

vector<int> label(int n,int k,vector<int> u,vector<int> v){
	l.resize(n,-1);
	for(int i=0;i<n-1;++i){
		++deg[u[i]];
		++deg[v[i]];
		AL[u[i]].pb(v[i]);
		AL[v[i]].pb(u[i]);
	}
	for(int i=0;i<n;++i){
		if(deg[i]==1){
			int u=i;
			l[u]=0;
			while(true){
				for(int v:AL[u]){
					if(l[v]==-1){
						l[v]=l[u]+1;
						u=v;break;
					}
				}
				if(AL[u].size()==1)break;
			}
			break;
		}
	}
	return l;
}

int find_next_station(int s,int t,vector<int> c){
	if(c.size()==1)return c[0];
	if(s>t&&s>c[0])return c[0];
	if(s>t&&s>c[1])return c[1];
	if(s<t&&s<c[0])return c[0];
	if(s<t&&s<c[1])return c[1];
	return c[0];
}
# Verdict Execution time Memory Grader output
1 Execution timed out 3055 ms 328 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3041 ms 312 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3079 ms 312 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 885 ms 496 KB Output is correct
2 Incorrect 662 ms 400 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3041 ms 308 KB Time limit exceeded
2 Halted 0 ms 0 KB -