답안 #896206

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
896206 2024-01-01T02:35:11 Z juliany2 Meetings 2 (JOI21_meetings2) C++17
4 / 100
4 ms 608 KB
#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;
}

# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -