Блог пользователя MrAutro

Автор MrAutro, история, 5 лет назад, По-английски

Hello I managed to understand the problem and what it needs but my idea is to use Catalan numbers to count number of binary trees but in problem it wants to count the number of BS trees of length n with height at least h and root and leafs included but I could not discard or exclude all count of trees of height less than h from Catalan numbers

Any hint please I will be thankful and grateful and thanks in advance

https://mirror.codeforces.com/problemset/problem/9/D

  • Проголосовать: нравится
  • -2
  • Проголосовать: не нравится

»
5 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

As you said you can't discard from Catalan numbers. I don't know any way to do this either. So you can assume this task is not related to Catalan. Actualy this task has an editorial.

  • »
    »
    5 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    I didn't understand the editorial for sorry

    • »
      »
      »
      5 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Where exactly misunderstanding? There just really simple recursion:

      T(n, h) — number of trees with n vertexes and height of h
      T(0, 0) = 1, T(0, i) = T(i, 0) = 0
      Fixing root m and parity all possible trees at trees of two types:

      1) Height of left subtree is h — 1 and height of right subtree is belongs to [0..h-1] 2) Height of left subtree is less than h — 1 and height of right subtree is exactly h — 1.