#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
const int N = 17;
int n;
vector<int> adj[N];
int sz[N], ans[N];
int cnt, cur;
void dfs(int v = 1, int p = 0) {
for (int u : adj[v]) {
if (u != p) {
dfs(u, v);
sz[v] += sz[u];
}
}
if (sz[v] == cnt / 2)
cur++;
}
int main() {
cin.tie(0)->sync_with_stdio(false);
cin >> n;
for (int i = 1; i < n; i++) {
int u, v;
cin >> u >> v;
u--, v--;
adj[u].push_back(v);
adj[v].push_back(u);
}
for (int mask = 1; mask < (1 << n); mask++) {
cnt = __builtin_popcount(mask), cur = 0;
if (cnt % 2)
continue;
for (int i = 0; i < n; i++)
sz[i] = mask >> i & 1;
dfs();
ans[cnt] = max(ans[cnt], cur + 1);
}
for (int i = 1; i <= n; i++)
cout << (i % 2 ? 1 : ans[i]) << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
4 ms |
348 KB |
Output is correct |
10 |
Correct |
4 ms |
348 KB |
Output is correct |
11 |
Correct |
4 ms |
348 KB |
Output is correct |
12 |
Correct |
4 ms |
348 KB |
Output is correct |
13 |
Correct |
4 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
460 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
3 ms |
352 KB |
Output is correct |
18 |
Correct |
3 ms |
352 KB |
Output is correct |
19 |
Correct |
2 ms |
352 KB |
Output is correct |
20 |
Correct |
3 ms |
460 KB |
Output is correct |
21 |
Correct |
2 ms |
352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
4 ms |
348 KB |
Output is correct |
10 |
Correct |
4 ms |
348 KB |
Output is correct |
11 |
Correct |
4 ms |
348 KB |
Output is correct |
12 |
Correct |
4 ms |
348 KB |
Output is correct |
13 |
Correct |
4 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
460 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
3 ms |
352 KB |
Output is correct |
18 |
Correct |
3 ms |
352 KB |
Output is correct |
19 |
Correct |
2 ms |
352 KB |
Output is correct |
20 |
Correct |
3 ms |
460 KB |
Output is correct |
21 |
Correct |
2 ms |
352 KB |
Output is correct |
22 |
Runtime error |
1 ms |
608 KB |
Execution killed with signal 11 |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
4 ms |
348 KB |
Output is correct |
10 |
Correct |
4 ms |
348 KB |
Output is correct |
11 |
Correct |
4 ms |
348 KB |
Output is correct |
12 |
Correct |
4 ms |
348 KB |
Output is correct |
13 |
Correct |
4 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
460 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
3 ms |
352 KB |
Output is correct |
18 |
Correct |
3 ms |
352 KB |
Output is correct |
19 |
Correct |
2 ms |
352 KB |
Output is correct |
20 |
Correct |
3 ms |
460 KB |
Output is correct |
21 |
Correct |
2 ms |
352 KB |
Output is correct |
22 |
Runtime error |
1 ms |
608 KB |
Execution killed with signal 11 |
23 |
Halted |
0 ms |
0 KB |
- |