Submission #569066

# Submission time Handle Problem Language Result Execution time Memory
569066 2022-05-26T14:49:11 Z minhcool Cat in a tree (BOI17_catinatree) C++17
11 / 100
93 ms 596 KB
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define foru(i, l, r) for(int i = l; i <= r; i++)
#define ford(i, r, l) for(int i = r; i >= l; i--)

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int N = 1e3 + 5;

const int oo = 1e18 + 7, mod = 1e9 + 7;

int n, d;
vector<int> Adj[N];

int dist[N][N];

void dfs(int u, int p, int root){
	for(auto v : Adj[u]){
		if(v == p) continue;
		dist[root][v] = dist[root][u] + 1;
		dfs(v, u, root);
	}
}

void process(){
	cin >> n >> d;
	for(int i = 1; i < n; i++){
		int x;
		cin >> x;
		Adj[x].pb(i);
		Adj[i].pb(x);
	}
	for(int i = 0; i < n; i++){
		dfs(i, i, i);
	}
	int mx = -1;
	for(int i = 0; i < (1LL << n); i++){
		vector<int> vc;
		for(int j = 0; j < n; j++) if(i & (1LL << j)) vc.pb(j);
		bool ck = 1;
		for(auto it : vc){
			for(auto it2 : vc){
				if(it == it2) continue;
				ck &= (dist[it][it2] >= d);
			}
		}
		if(ck) mx = max(mx, (int)vc.size());
	}
	cout << mx;
}

signed main(){
	ios_base::sync_with_stdio(0);
	process();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 5 ms 356 KB Output is correct
6 Correct 5 ms 340 KB Output is correct
7 Correct 28 ms 340 KB Output is correct
8 Correct 27 ms 416 KB Output is correct
9 Correct 81 ms 340 KB Output is correct
10 Correct 79 ms 408 KB Output is correct
11 Correct 82 ms 404 KB Output is correct
12 Correct 88 ms 340 KB Output is correct
13 Correct 49 ms 460 KB Output is correct
14 Correct 39 ms 412 KB Output is correct
15 Correct 77 ms 340 KB Output is correct
16 Correct 83 ms 340 KB Output is correct
17 Correct 76 ms 340 KB Output is correct
18 Correct 93 ms 340 KB Output is correct
19 Correct 85 ms 404 KB Output is correct
20 Correct 82 ms 404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 5 ms 356 KB Output is correct
6 Correct 5 ms 340 KB Output is correct
7 Correct 28 ms 340 KB Output is correct
8 Correct 27 ms 416 KB Output is correct
9 Correct 81 ms 340 KB Output is correct
10 Correct 79 ms 408 KB Output is correct
11 Correct 82 ms 404 KB Output is correct
12 Correct 88 ms 340 KB Output is correct
13 Correct 49 ms 460 KB Output is correct
14 Correct 39 ms 412 KB Output is correct
15 Correct 77 ms 340 KB Output is correct
16 Correct 83 ms 340 KB Output is correct
17 Correct 76 ms 340 KB Output is correct
18 Correct 93 ms 340 KB Output is correct
19 Correct 85 ms 404 KB Output is correct
20 Correct 82 ms 404 KB Output is correct
21 Runtime error 1 ms 596 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 5 ms 356 KB Output is correct
6 Correct 5 ms 340 KB Output is correct
7 Correct 28 ms 340 KB Output is correct
8 Correct 27 ms 416 KB Output is correct
9 Correct 81 ms 340 KB Output is correct
10 Correct 79 ms 408 KB Output is correct
11 Correct 82 ms 404 KB Output is correct
12 Correct 88 ms 340 KB Output is correct
13 Correct 49 ms 460 KB Output is correct
14 Correct 39 ms 412 KB Output is correct
15 Correct 77 ms 340 KB Output is correct
16 Correct 83 ms 340 KB Output is correct
17 Correct 76 ms 340 KB Output is correct
18 Correct 93 ms 340 KB Output is correct
19 Correct 85 ms 404 KB Output is correct
20 Correct 82 ms 404 KB Output is correct
21 Runtime error 1 ms 596 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -