Submission #432417

# Submission time Handle Problem Language Result Execution time Memory
432417 2021-06-18T09:24:07 Z milleniumEeee Stations (IOI20_stations) C++17
0 / 100
926 ms 792 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);
		}
	}
	return labels;
}
 
int find_next_station(int s, int t, vector<int> c) {
	if (s == 0) {
		return t;
	} else {
		return c[0];
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 535 ms 704 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 432 ms 792 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 538 ms 716 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 926 ms 728 KB Output is correct
2 Correct 698 ms 784 KB Output is correct
3 Incorrect 634 ms 656 KB Wrong query response.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 508 ms 708 KB Wrong query response.
2 Halted 0 ms 0 KB -