Submission #381707

# Submission time Handle Problem Language Result Execution time Memory
381707 2021-03-25T17:55:59 Z b00n0rp Stations (IOI20_stations) C++17
0 / 100
920 ms 1068 KB
#include<bits/stdc++.h>
#include "stations.h"

using namespace std;

#define vi vector<int>
#define pb push_back
#define REP(i,n) for(int i = 0; i < n; i ++)
#define FOR(i,a,b) for(int i = a; i < b; i ++)

const int MAXN = 1005;

int st[MAXN],fin[MAXN],dep[MAXN],tim = 0;
vi adj[MAXN];

void dfs(int u,int p,int d){
	if(d%2 == 0) st[u] = tim++;
	dep[u] = d;
	for(auto v:adj[u]){
		if(v != p) dfs(v,u,d+1);
	}
	if(d%2 == 1) fin[u] = tim++;
}

vi label(int n, int k, vi u, vi v){
	tim = 0;
	REP(i,n) adj[i].clear();
	vi labels(n);
	REP(i,n-1){
		adj[u[i]].pb(v[i]);
		adj[v[i]].pb(u[i]);
	}
	dfs(0,0,0);
	for (int i = 0; i < n; i++){
		if(dep[i]%2 == 0) labels[i] = st[i];
		else labels[i] = fin[i];
	}
	return labels;
}

int find_next_station(int s, int t, vi c){
	if(c.size() == 1) return c[0];
	for(auto x:c){
		if(x == t) return x;
	}
	sort(c.begin(),c.end());
	if(s < c[0]){
		if(t < s) return c.back();
		for(auto x:c){
			if(t < x) return x;
		}
		return c.back();
	}
	else{
		if(t > s) return c[0];
		for(auto x:c){
			if(t > x) return x;
		}
		return c[0];
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 585 ms 1068 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 451 ms 864 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 590 ms 1064 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 920 ms 940 KB Output is correct
2 Correct 817 ms 940 KB Output is correct
3 Incorrect 655 ms 960 KB Wrong query response.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 633 ms 812 KB Wrong query response.
2 Halted 0 ms 0 KB -