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

Автор yesnomaybe, история, 4 года назад, По-английски

P0, P1, ...., Pn players in tournament. In first level, P0 plays with P1, P2 plays with P3 and so on. In level 2, Winner of P0,P1 plays with winner of P2,P3. For i,j output level in which they will face each other assuming they win all games.

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

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

Imagine the numbers 0 to n as the leaves of a binary tree of height ceil(log(n)). Suppose leaves are the level 0. After every match, a player moves up a level. So I think the level of LCA(as defined here) is the answer.

Could be wrong, I would solve it like this.