Submission #387230

# Submission time Handle Problem Language Result Execution time Memory
387230 2021-04-08T06:57:17 Z milleniumEeee Fun Tour (APIO20_fun) C++17
26 / 100
19 ms 5484 KB
////////////////////////////////
#include "fun.h"
//#include "grader.cpp"
////////////////////////////////
#include <bits/stdc++.h>
#define pb push_back
#define szof(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define pii pair<int, int>
using namespace std;

const int MAXN = (int)1e5 + 5;
const int MAXQ = (int)4e5 + 5;

vector <int> g[MAXN];
bool used[MAXN];
int dist[MAXN];
int n;

void calc(int v, int par, int len) {
	dist[v] = len;
	for (int to : g[v]) {
		if (to == par) {
			continue;
		}
		calc(to, v, len + 1);
	}
}

int get_max() {
	int pos = -1, mx = 0;
	for (int i = 0; i < n; i++) {
		if (!used[i] && dist[i] > mx) {
			mx = dist[i];
			pos = i;
		}
	}
	return pos;
}

vector <int> vec[100];

void build(int v, int level = 0) {
	vec[level].pb(v);
	if (v * 2 + 1 < n) {
		build(v * 2 + 1, level + 1);
	}
	if (v * 2 + 2 < n) {
		build(v * 2 + 2, level + 1);
	}
}

vector <int> createFunTour(int N, int Q) {
	n = N;
	if (N <= 500) {
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (hoursRequired(i, j) == 1) {
					g[i].pb(j);
					g[j].pb(i);
				}
			}
		}
		int a = 1;
		calc(a, -1, 0);
		int b = get_max();
		calc(b, -1, 0);
		int c = get_max();
		vector <int> ans = {b, c};
		used[b] = used[c] = 1;
		int used_cnt = 2;
		int last = c;
		while (used_cnt < n) {
			calc(last, -1, 0);
			int nxt = get_max();
			last = nxt;
			ans.pb(nxt);
			used[last] = 1;
			used_cnt++;
		}
		return ans;
	}
	assert(false);
}
/*
3 400000
0 1
0 2
1 3
1 4
2 5
2 6
3 7
3 8
4 9
4 10
5 11
5 12 
6 13
6 14
*/
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2624 KB Output is correct
2 Correct 3 ms 2668 KB Output is correct
3 Correct 3 ms 2668 KB Output is correct
4 Correct 3 ms 2668 KB Output is correct
5 Correct 3 ms 2668 KB Output is correct
6 Correct 3 ms 2668 KB Output is correct
7 Correct 3 ms 2668 KB Output is correct
8 Correct 3 ms 2668 KB Output is correct
9 Correct 4 ms 2668 KB Output is correct
10 Correct 3 ms 2668 KB Output is correct
11 Correct 3 ms 2668 KB Output is correct
12 Correct 3 ms 2668 KB Output is correct
13 Correct 3 ms 2668 KB Output is correct
14 Correct 3 ms 2668 KB Output is correct
15 Correct 3 ms 2668 KB Output is correct
16 Correct 3 ms 2668 KB Output is correct
17 Correct 3 ms 2668 KB Output is correct
18 Correct 3 ms 2668 KB Output is correct
19 Correct 3 ms 2668 KB Output is correct
20 Correct 3 ms 2668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2624 KB Output is correct
2 Correct 3 ms 2668 KB Output is correct
3 Correct 3 ms 2668 KB Output is correct
4 Correct 3 ms 2668 KB Output is correct
5 Correct 3 ms 2668 KB Output is correct
6 Correct 3 ms 2668 KB Output is correct
7 Correct 3 ms 2668 KB Output is correct
8 Correct 3 ms 2668 KB Output is correct
9 Correct 4 ms 2668 KB Output is correct
10 Correct 3 ms 2668 KB Output is correct
11 Correct 3 ms 2668 KB Output is correct
12 Correct 3 ms 2668 KB Output is correct
13 Correct 3 ms 2668 KB Output is correct
14 Correct 3 ms 2668 KB Output is correct
15 Correct 3 ms 2668 KB Output is correct
16 Correct 3 ms 2668 KB Output is correct
17 Correct 3 ms 2668 KB Output is correct
18 Correct 3 ms 2668 KB Output is correct
19 Correct 3 ms 2668 KB Output is correct
20 Correct 3 ms 2668 KB Output is correct
21 Correct 3 ms 2668 KB Output is correct
22 Correct 3 ms 2668 KB Output is correct
23 Correct 3 ms 2668 KB Output is correct
24 Correct 15 ms 2796 KB Output is correct
25 Correct 3 ms 2668 KB Output is correct
26 Correct 3 ms 2668 KB Output is correct
27 Correct 4 ms 2668 KB Output is correct
28 Correct 3 ms 2668 KB Output is correct
29 Correct 16 ms 2796 KB Output is correct
30 Correct 3 ms 2668 KB Output is correct
31 Correct 5 ms 2668 KB Output is correct
32 Correct 7 ms 2668 KB Output is correct
33 Correct 3 ms 2668 KB Output is correct
34 Correct 19 ms 2796 KB Output is correct
35 Correct 16 ms 2796 KB Output is correct
36 Correct 18 ms 2796 KB Output is correct
37 Correct 3 ms 2668 KB Output is correct
38 Correct 17 ms 2796 KB Output is correct
39 Correct 7 ms 2668 KB Output is correct
40 Correct 10 ms 2668 KB Output is correct
41 Correct 5 ms 2668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2668 KB Output is correct
2 Correct 3 ms 2668 KB Output is correct
3 Correct 3 ms 2668 KB Output is correct
4 Correct 3 ms 2668 KB Output is correct
5 Correct 3 ms 2668 KB Output is correct
6 Correct 3 ms 2668 KB Output is correct
7 Correct 3 ms 2668 KB Output is correct
8 Correct 4 ms 2668 KB Output is correct
9 Correct 3 ms 2668 KB Output is correct
10 Correct 3 ms 2668 KB Output is correct
11 Correct 3 ms 2668 KB Output is correct
12 Correct 15 ms 2796 KB Output is correct
13 Correct 3 ms 2668 KB Output is correct
14 Correct 3 ms 2668 KB Output is correct
15 Correct 4 ms 2668 KB Output is correct
16 Runtime error 6 ms 5356 KB Execution killed with signal 6
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2668 KB Output is correct
2 Correct 3 ms 2668 KB Output is correct
3 Correct 3 ms 2668 KB Output is correct
4 Correct 3 ms 2668 KB Output is correct
5 Correct 3 ms 2668 KB Output is correct
6 Correct 3 ms 2668 KB Output is correct
7 Correct 3 ms 2668 KB Output is correct
8 Correct 16 ms 2796 KB Output is correct
9 Correct 3 ms 2668 KB Output is correct
10 Correct 5 ms 2668 KB Output is correct
11 Correct 7 ms 2668 KB Output is correct
12 Correct 3 ms 2668 KB Output is correct
13 Runtime error 7 ms 5484 KB Execution killed with signal 6
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2624 KB Output is correct
2 Correct 3 ms 2668 KB Output is correct
3 Correct 3 ms 2668 KB Output is correct
4 Correct 3 ms 2668 KB Output is correct
5 Correct 3 ms 2668 KB Output is correct
6 Correct 3 ms 2668 KB Output is correct
7 Correct 3 ms 2668 KB Output is correct
8 Correct 3 ms 2668 KB Output is correct
9 Correct 4 ms 2668 KB Output is correct
10 Correct 3 ms 2668 KB Output is correct
11 Correct 3 ms 2668 KB Output is correct
12 Correct 3 ms 2668 KB Output is correct
13 Correct 3 ms 2668 KB Output is correct
14 Correct 3 ms 2668 KB Output is correct
15 Correct 3 ms 2668 KB Output is correct
16 Correct 3 ms 2668 KB Output is correct
17 Correct 3 ms 2668 KB Output is correct
18 Correct 3 ms 2668 KB Output is correct
19 Correct 3 ms 2668 KB Output is correct
20 Correct 3 ms 2668 KB Output is correct
21 Correct 3 ms 2668 KB Output is correct
22 Correct 3 ms 2668 KB Output is correct
23 Correct 3 ms 2668 KB Output is correct
24 Correct 15 ms 2796 KB Output is correct
25 Correct 3 ms 2668 KB Output is correct
26 Correct 3 ms 2668 KB Output is correct
27 Correct 4 ms 2668 KB Output is correct
28 Correct 3 ms 2668 KB Output is correct
29 Correct 16 ms 2796 KB Output is correct
30 Correct 3 ms 2668 KB Output is correct
31 Correct 5 ms 2668 KB Output is correct
32 Correct 7 ms 2668 KB Output is correct
33 Correct 3 ms 2668 KB Output is correct
34 Correct 19 ms 2796 KB Output is correct
35 Correct 16 ms 2796 KB Output is correct
36 Correct 18 ms 2796 KB Output is correct
37 Correct 3 ms 2668 KB Output is correct
38 Correct 17 ms 2796 KB Output is correct
39 Correct 7 ms 2668 KB Output is correct
40 Correct 10 ms 2668 KB Output is correct
41 Correct 5 ms 2668 KB Output is correct
42 Runtime error 6 ms 5356 KB Execution killed with signal 6
43 Halted 0 ms 0 KB -