Submission #380298

# Submission time Handle Problem Language Result Execution time Memory
380298 2021-03-20T22:54:48 Z SuhaibSawalha1 Stations (IOI20_stations) C++17
5 / 100
1037 ms 1140 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;

vector<vector<int>> adj;
int n;
vector<int> lb, ord;

void dfs (int u, int p = -1) {
	ord.push_back(u);
	for (int v : adj[u]) {
		if (v ^ p) {
			dfs(v, u);
		}
	}
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	::n = n;
	ord.clear();
	adj.assign(n, {});
	lb.resize(n);
	for (int i = 0; i < n - 1; ++i) {
		adj[u[i]].push_back(v[i]);
		adj[v[i]].push_back(u[i]);
	}
	for (int i = 0; i < n; ++i) {
		if (adj[i].size() == 1) {
			dfs(i);
			break;
		}
	}
	for (int i = 0; i < n; ++i) {
		lb[ord[i]] = i;
	}
	return lb;
}

int find_next_station(int s, int t, vector<int> c) {
	return s - (s > t) + (s < t);
}
# Verdict Execution time Memory Grader output
1 Correct 576 ms 816 KB Output is correct
2 Correct 478 ms 864 KB Output is correct
3 Correct 922 ms 756 KB Output is correct
4 Correct 662 ms 756 KB Output is correct
5 Correct 605 ms 736 KB Output is correct
6 Correct 516 ms 992 KB Output is correct
7 Correct 575 ms 1128 KB Output is correct
8 Correct 3 ms 756 KB Output is correct
9 Correct 4 ms 756 KB Output is correct
10 Correct 2 ms 756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 487 ms 988 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 571 ms 884 KB Output is correct
2 Correct 489 ms 876 KB Output is correct
3 Correct 893 ms 736 KB Output is correct
4 Correct 708 ms 756 KB Output is correct
5 Correct 641 ms 756 KB Output is correct
6 Correct 519 ms 864 KB Output is correct
7 Correct 515 ms 1000 KB Output is correct
8 Correct 3 ms 756 KB Output is correct
9 Correct 5 ms 736 KB Output is correct
10 Correct 2 ms 736 KB Output is correct
11 Incorrect 689 ms 864 KB Wrong query response.
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 919 ms 868 KB Output is correct
2 Correct 728 ms 756 KB Output is correct
3 Correct 685 ms 736 KB Output is correct
4 Correct 3 ms 868 KB Output is correct
5 Correct 5 ms 736 KB Output is correct
6 Correct 2 ms 756 KB Output is correct
7 Incorrect 649 ms 864 KB Wrong query response.
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 605 ms 1140 KB Output is correct
2 Correct 453 ms 884 KB Output is correct
3 Correct 1037 ms 1072 KB Output is correct
4 Correct 786 ms 756 KB Output is correct
5 Correct 736 ms 736 KB Output is correct
6 Correct 645 ms 884 KB Output is correct
7 Correct 568 ms 1000 KB Output is correct
8 Correct 3 ms 876 KB Output is correct
9 Correct 4 ms 884 KB Output is correct
10 Correct 2 ms 756 KB Output is correct
11 Incorrect 594 ms 884 KB Wrong query response.
12 Halted 0 ms 0 KB -