Submission #432425

# Submission time Handle Problem Language Result Execution time Memory
432425 2021-06-18T09:35:03 Z milleniumEeee Stations (IOI20_stations) C++17
0 / 100
831 ms 840 KB
#ifndef EVAL
#include "stub.cpp"
#endif
#include "stations.h"
 
#include <bits/stdc++.h>
#define fr first
#define sc second
#define pii pair<int, int>
#define pb push_back
#define szof(s) (int)s.size()
#define all(s) s.begin(), s.end()
 
using namespace std;
 
const int MAXN = 2005;
 
vector <int> G[MAXN]; // binary tree
vector <int> g[MAXN]; // cur component
 
void clean() {
	for (int i = 0; i < MAXN; i++) {
		g[i].clear();
	}
}
 
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	clean();
	set <int> id;
	for (int i = 0; i < n; i++) {
		id.insert(i);
	}
	vector <int> cnt(n, 0);
	int center = 0;
	for (int i = 0; i <= n - 2; i++) {
		int x = u[i];
		int y = v[i];
		cnt[x]++;
		cnt[y]++;
		if (cnt[x] >= 2) {
			center = x;
		}
		if (cnt[y] >= 2) {
			center = y;
		}
	}
	vector <int> labels(n);
	for (int i = 0; i < n; i++) {
		if (center == i) {
			labels[i] = 0;
			id.erase(0);
		} else {
			auto it = --id.end();
			labels[i] = *it;
			id.erase(it);
		}
	}
	if (n >= 3) {
		assert(cnt[center] >= 2);
		assert(labels[center] == 0);
	}
	return labels;
}
 
int find_next_station(int s, int t, vector<int> c) {
	if (binary_search(all(c), t)) {
		return t;
	} else {
		return 0;
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 542 ms 784 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 457 ms 784 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 516 ms 840 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 831 ms 692 KB Output is correct
2 Correct 714 ms 708 KB Output is correct
3 Incorrect 597 ms 656 KB Wrong query response.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 500 ms 704 KB Wrong query response.
2 Halted 0 ms 0 KB -