Submission #672885

# Submission time Handle Problem Language Result Execution time Memory
672885 2022-12-18T20:09:18 Z mars Stations (IOI20_stations) C++17
0 / 100
812 ms 548 KB
#include <vector>
#include <algorithm>
//#include "IOI20_Stations.h"
//const int N = 1e5;
int cnt=0;

std::vector<int> labels;

/*
clarifications:
k == n-1
c is sorted


Debugging:
- Idea => Proof
- Code => Accepted

*/

std::vector<std::vector<int>> g;
void dfs(int node, int par) {
	labels[node] = cnt++;
	for (int ch : g[node]) {
		if (ch != par) {
			dfs(ch, node);
		}
	}
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	g.clear();
	g.resize(n);
	cnt = 1;
	for (int i = 0; i < n - 1;i++) {
		g[u[i]].push_back(v[i]);
		g[v[i]].push_back(u[i]);
	}
	//cnt = 0;
	labels.clear();
	labels.resize(n);
	dfs(0, -1);
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
	int sz = c.size();
	if (s > t) return c[0];
	for (int i = 1; i < sz-1; i++) {
		if (t >= c[i] && t < c[i + 1]) return c[i];
	}
	return c[sz - 1];
}
# Verdict Execution time Memory Grader output
1 Incorrect 462 ms 544 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 467 ms 496 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 532 ms 536 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 812 ms 480 KB Output is correct
2 Incorrect 635 ms 496 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 549 ms 548 KB Wrong query response.
2 Halted 0 ms 0 KB -