Submission #413224

# Submission time Handle Problem Language Result Execution time Memory
413224 2021-05-28T11:28:57 Z SuhaibSawalha1 Stations (IOI20_stations) C++17
5 / 100
1172 ms 744 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
 
vector<vector<int>> adj;
vector<int> lab;
int cnt;
 
void dfs (int u, int p = -1) {
	for (int v : adj[u]) {
		if (v ^ p) {
			dfs(v, u);
		}
	}
	lab[u] = cnt++;
}
 
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	adj.assign(n, {});
	lab.resize(n);
	cnt = 0;
	for (int i = 0; i < n - 1; ++i) {
		adj[u[i]].push_back(v[i]);
		adj[v[i]].push_back(u[i]);
	}
	if (all_of(adj.begin(), adj.end(), [](auto &e) {return e.size() < 3;})) {
		for (int i = 0; i < n; ++i) {
			if (adj[i].size() == 1) {
				dfs(i);
				break;
			}
		}
		return lab;
	}
	iota(lab.begin(), lab.end(), 0);
	return lab;
}
 
int find_next_station(int s, int t, vector<int> c) {
	sort(c.begin(), c.end());
	vector<int> y{(s - 1) / 2, 2 * s + 1, 2 * s + 2};
	while (y.size() > c.size()) {
		y.pop_back();
	}
	if (y != c) {
		return s - (t < s) + (t > s);
	}
	int e = t;
	while (e) {
		int p = (e - 1) / 2;
		if (p == s) {
			return e;
		}
		e = p;
	}
	return (s - 1) / 2;
}
# Verdict Execution time Memory Grader output
1 Correct 702 ms 612 KB Output is correct
2 Correct 572 ms 620 KB Output is correct
3 Correct 1154 ms 400 KB Output is correct
4 Correct 653 ms 616 KB Output is correct
5 Correct 868 ms 400 KB Output is correct
6 Correct 664 ms 744 KB Output is correct
7 Correct 538 ms 488 KB Output is correct
8 Correct 4 ms 464 KB Output is correct
9 Correct 6 ms 476 KB Output is correct
10 Correct 2 ms 428 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 633 ms 492 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 611 ms 672 KB Output is correct
2 Correct 587 ms 528 KB Output is correct
3 Correct 1073 ms 404 KB Output is correct
4 Correct 713 ms 400 KB Output is correct
5 Correct 797 ms 476 KB Output is correct
6 Correct 438 ms 528 KB Output is correct
7 Correct 579 ms 488 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 5 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Incorrect 656 ms 484 KB Wrong query response.
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 988 ms 480 KB Output is correct
2 Correct 852 ms 528 KB Output is correct
3 Correct 659 ms 484 KB Output is correct
4 Correct 5 ms 460 KB Output is correct
5 Correct 4 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Incorrect 644 ms 400 KB Wrong query response.
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 636 ms 740 KB Output is correct
2 Correct 571 ms 616 KB Output is correct
3 Correct 1172 ms 400 KB Output is correct
4 Correct 860 ms 488 KB Output is correct
5 Correct 737 ms 616 KB Output is correct
6 Correct 633 ms 528 KB Output is correct
7 Correct 580 ms 656 KB Output is correct
8 Correct 4 ms 468 KB Output is correct
9 Correct 6 ms 456 KB Output is correct
10 Correct 2 ms 480 KB Output is correct
11 Incorrect 598 ms 580 KB Wrong query response.
12 Halted 0 ms 0 KB -