Submission #416677

# Submission time Handle Problem Language Result Execution time Memory
416677 2021-06-02T18:08:17 Z Dilshod_Imomov Stations (IOI20_stations) C++17
0 / 100
969 ms 55452 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
 
const int MAXN = 1e3 + 7;
 
void dfs( vector<vector<int>> adj, int v, int p, int h, vector<int> &lb, int &cnt ) {
	for ( auto u: adj[v] ) {
		if ( u != p ) {
			dfs( adj, u, v, h + 1, lb, cnt );
		}
	}
	lb[v] = cnt++;
}
 
 
vector<int> label(int n, int k, vector<int> U, vector<int> V) {
	vector < vector < int > > adj(n + 1);
	for ( int i = 0; i < n - 1; i++ ) {
		int u = U[i], v = V[i];
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	vector < int > lb(n);
	int cnt = 0;
	dfs( adj, 0, -1, 0, lb, cnt );
	return lb;
}
 
int find_next_station(int s, int t, vector<int> c) {
	int pr = -1;
	if ( c.back() > s ) {
		pr = c.back();
		c.pop_back();
	}
	// cout << tins << ' ' << touts << ' ' << pr << endl;
	for ( auto u: c ) {
		if ( t <= u) {
			return u;
		}
	}
	assert( pr != -1 );
	return pr;
}
# Verdict Execution time Memory Grader output
1 Incorrect 831 ms 55444 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 969 ms 1012 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 778 ms 55452 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 833 ms 476 KB Output is correct
2 Correct 609 ms 520 KB Output is correct
3 Incorrect 585 ms 520 KB Wrong query response.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 858 ms 55432 KB Wrong query response.
2 Halted 0 ms 0 KB -