답안 #432557

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
432557 2021-06-18T11:03:37 Z milleniumEeee 기지국 (IOI20_stations) C++17
10 / 100
930 ms 732 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 = 1005;

vector <int> g[MAXN];
int tin[MAXN], tout[MAXN], tiktak = 0;
int pr[MAXN];

void clean() {
	for (int i = 0; i < MAXN; i++) {
		g[i].clear();
		tin[i] = 0;
		tout[i] = 0;
		pr[i] = 0;
	}
	tiktak = 0;
}


void precalc(int v, int par) {
	tin[v] = ++tiktak;
	pr[v] = par;
	for (int to : g[v]) {
		if (to != par) {
			precalc(to, v);
		}
	}
	tout[v] = tiktak;
}

void up(int v, vector <int> &vec) {
	vec.pb(v);
	if (pr[v] != -1) {
		up(pr[v], vec);
	}
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	clean(); // на всякий случай
	for (int i = 0; i <= n - 2; i++) {
		int x = u[i];
		int y = v[i];
		g[x].pb(y);
		g[y].pb(x);
	}
	precalc(0, -1);
	vector <int> labels(n);
	for (int i = 0; i < n; i++) {
		vector <int> vec;
		up(i, vec);
		int mask = 0;
		for (int el : vec) {
			mask += (1 << el);
		}
		labels[i] = mask;
	}
	return labels;
}

bool father(int a, int b) {
	return ((a & b) == a);
}

int find_next_station(int s, int t, vector<int> c) {
	if (father(s, t)) {
		for (int el : c) {
			if (father(s, el) && father(el, t)) {
				return el;
			}
		}
	}
	for (int el : c) {
		if (father(el, s)) {
			return el;
		}
	}
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:90:1: warning: control reaches end of non-void function [-Wreturn-type]
   90 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 328 KB Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=8912933
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 328 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=10, label=1043
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 308 KB Invalid labels (values out of range). scenario=1, k=1000000, vertex=1, label=742244405
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 930 ms 564 KB Output is correct
2 Correct 684 ms 580 KB Output is correct
3 Correct 567 ms 520 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 5 ms 596 KB Output is correct
6 Correct 2 ms 636 KB Output is correct
7 Correct 565 ms 520 KB Output is correct
8 Correct 867 ms 516 KB Output is correct
9 Correct 613 ms 528 KB Output is correct
10 Correct 579 ms 732 KB Output is correct
11 Correct 8 ms 596 KB Output is correct
12 Correct 6 ms 468 KB Output is correct
13 Correct 4 ms 468 KB Output is correct
14 Correct 4 ms 596 KB Output is correct
15 Correct 2 ms 596 KB Output is correct
16 Correct 493 ms 552 KB Output is correct
17 Correct 458 ms 660 KB Output is correct
18 Correct 390 ms 400 KB Output is correct
19 Correct 468 ms 400 KB Output is correct
20 Correct 512 ms 520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 18 ms 304 KB Invalid labels (values out of range). scenario=1, k=1000000000, vertex=2, label=-538475768
2 Halted 0 ms 0 KB -