Submission #474914

# Submission time Handle Problem Language Result Execution time Memory
474914 2021-09-20T09:38:02 Z 600Mihnea Meetings 2 (JOI21_meetings2) C++17
20 / 100
4000 ms 12132 KB
#include <bits/stdc++.h>

using namespace std;

const int N = (int) 2e5 + 7;
int n, sub[N], sol[N];
vector<int> g[N];

void build(int a, int p = -1) {
  sub[a] = 1;
  for (auto &b : g[a]) {
    if (b == p) continue;
    build(b, a);
    sub[a] += sub[b];
  }
}

void dfs(int a, int p, int thr, int len) {
  if (sub[a] < thr) return;
  sol[thr] = max(sol[thr], len);
  for (auto &b : g[a]) {
    if (b == p) continue;
    dfs(b, a, thr, len + 1);
  }

}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);

  cin >> n;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }

  for (int root = 1; root <= n; root++) {
    build(root);
    for (auto &i : g[root]) {
      dfs(i, root, n - sub[i], 1);
    }
  }

  for (int i = n; i >= 1; i--) {
    sol[i] = max(sol[i], sol[i + 1]);
  }

  for (int i = 1; i <= n; i++) {
    if (i & 1) {
      cout << 1 << "\n";
    } else {
      cout << sol[i / 2] + 1 << "\n";
    }
  }

  return 0;
}

/**

**/
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 3 ms 4940 KB Output is correct
7 Correct 3 ms 4940 KB Output is correct
8 Correct 3 ms 4940 KB Output is correct
9 Correct 4 ms 4940 KB Output is correct
10 Correct 3 ms 4940 KB Output is correct
11 Correct 3 ms 4940 KB Output is correct
12 Correct 3 ms 4940 KB Output is correct
13 Correct 4 ms 4940 KB Output is correct
14 Correct 3 ms 4940 KB Output is correct
15 Correct 3 ms 4940 KB Output is correct
16 Correct 3 ms 4940 KB Output is correct
17 Correct 3 ms 4940 KB Output is correct
18 Correct 3 ms 4940 KB Output is correct
19 Correct 4 ms 4940 KB Output is correct
20 Correct 3 ms 4940 KB Output is correct
21 Correct 4 ms 4940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 3 ms 4940 KB Output is correct
7 Correct 3 ms 4940 KB Output is correct
8 Correct 3 ms 4940 KB Output is correct
9 Correct 4 ms 4940 KB Output is correct
10 Correct 3 ms 4940 KB Output is correct
11 Correct 3 ms 4940 KB Output is correct
12 Correct 3 ms 4940 KB Output is correct
13 Correct 4 ms 4940 KB Output is correct
14 Correct 3 ms 4940 KB Output is correct
15 Correct 3 ms 4940 KB Output is correct
16 Correct 3 ms 4940 KB Output is correct
17 Correct 3 ms 4940 KB Output is correct
18 Correct 3 ms 4940 KB Output is correct
19 Correct 4 ms 4940 KB Output is correct
20 Correct 3 ms 4940 KB Output is correct
21 Correct 4 ms 4940 KB Output is correct
22 Correct 502 ms 5068 KB Output is correct
23 Correct 497 ms 5172 KB Output is correct
24 Correct 492 ms 5160 KB Output is correct
25 Correct 501 ms 5152 KB Output is correct
26 Correct 487 ms 5148 KB Output is correct
27 Correct 496 ms 5152 KB Output is correct
28 Correct 552 ms 5156 KB Output is correct
29 Correct 513 ms 5148 KB Output is correct
30 Correct 504 ms 5156 KB Output is correct
31 Correct 504 ms 5156 KB Output is correct
32 Correct 432 ms 5304 KB Output is correct
33 Correct 365 ms 5444 KB Output is correct
34 Correct 410 ms 5168 KB Output is correct
35 Correct 247 ms 5188 KB Output is correct
36 Correct 309 ms 5180 KB Output is correct
37 Correct 245 ms 5184 KB Output is correct
38 Correct 348 ms 5280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 3 ms 4940 KB Output is correct
7 Correct 3 ms 4940 KB Output is correct
8 Correct 3 ms 4940 KB Output is correct
9 Correct 4 ms 4940 KB Output is correct
10 Correct 3 ms 4940 KB Output is correct
11 Correct 3 ms 4940 KB Output is correct
12 Correct 3 ms 4940 KB Output is correct
13 Correct 4 ms 4940 KB Output is correct
14 Correct 3 ms 4940 KB Output is correct
15 Correct 3 ms 4940 KB Output is correct
16 Correct 3 ms 4940 KB Output is correct
17 Correct 3 ms 4940 KB Output is correct
18 Correct 3 ms 4940 KB Output is correct
19 Correct 4 ms 4940 KB Output is correct
20 Correct 3 ms 4940 KB Output is correct
21 Correct 4 ms 4940 KB Output is correct
22 Correct 502 ms 5068 KB Output is correct
23 Correct 497 ms 5172 KB Output is correct
24 Correct 492 ms 5160 KB Output is correct
25 Correct 501 ms 5152 KB Output is correct
26 Correct 487 ms 5148 KB Output is correct
27 Correct 496 ms 5152 KB Output is correct
28 Correct 552 ms 5156 KB Output is correct
29 Correct 513 ms 5148 KB Output is correct
30 Correct 504 ms 5156 KB Output is correct
31 Correct 504 ms 5156 KB Output is correct
32 Correct 432 ms 5304 KB Output is correct
33 Correct 365 ms 5444 KB Output is correct
34 Correct 410 ms 5168 KB Output is correct
35 Correct 247 ms 5188 KB Output is correct
36 Correct 309 ms 5180 KB Output is correct
37 Correct 245 ms 5184 KB Output is correct
38 Correct 348 ms 5280 KB Output is correct
39 Execution timed out 4082 ms 12132 KB Time limit exceeded
40 Halted 0 ms 0 KB -