Submission #354684

# Submission time Handle Problem Language Result Execution time Memory
354684 2021-01-22T04:54:53 Z Dilshod_Imomov Stations (IOI20_stations) C++17
0 / 100
919 ms 1248 KB
#include "stations.h"
#include <bits/stdc++.h>

using namespace std;

const int N = 1e3 + 7;

vector < int > lb, adj[N];
int num;

void dfs( int v, int pr ) {
	lb[v] = num++;
	// cout << "v -> " << v << ' ' << num - 1 << endl;
	for ( auto u: adj[v] ) {
		if ( u != pr ) {
			dfs(u, v);
		}
	}
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	for ( int i = 0; i < n; i++ ) {
		adj[i].clear();
	}
	for ( int i = 0; i < n - 1; i++ ) {
		int x = u[i], y = v[i];
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	num = 0;
	lb.clear();
	lb.resize(n);
	dfs(0, -1);
	return lb;
}

int find_next_station(int s, int t, std::vector<int> c) {
	int pr = c[0];
	for ( auto x: c ) {
		if ( x == pr ) {
			continue;
		}
		if ( x > t ) {
			break;
		}
		pr = x;
	}
	return pr;
}
# Verdict Execution time Memory Grader output
1 Incorrect 525 ms 864 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 432 ms 748 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 511 ms 1104 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 919 ms 1024 KB Output is correct
2 Correct 853 ms 1248 KB Output is correct
3 Incorrect 655 ms 864 KB Wrong query response.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 626 ms 992 KB Wrong query response.
2 Halted 0 ms 0 KB -