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

Автор ama_teur, 11 лет назад, По-английски

I have been stuck at this problem for quite sometime

http://codeforces.me/problemset/problem/234/G

I will be grateful if someone can assist me on this. I fail to understand how we to prove the optimality condition as well as how to enumerate the team configuration.

Thanks in advance.

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

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

Let the minimum number of practices for n players be f(n). Consider the first practice. The n players are split into teams of k and n - k players. In the remaining matches, any two players among the first team still need to play with each other because they have not done so in the first practice. Now we face a familiar problem: what is the minimum number of practices for k players to have each pair play with each other? The answer is f(k) because we can safely ignore the other n - k players because they do not affect whether two players among the k players play with each other or not. So f(n) - 1 >  = f(k). Note that there is nothing special about the first team. So we can use the same logic to the second team and deduce that f(n) - 1 ≥ f(n - k). So f(n) - 1 ≥ max(f(k), f(n - k)) for some 1 ≤ k ≤ n. We can easily prove by induction that this relation and the base case f(1) = 0 implies that f(n) ≥ ⌈log2n.

Now we see how f(n) = ⌈log2n can be achieved. Let the players be numbered 0, 1, ..., n - 1. Let the i th match be such that all players in the first team have the i th bit in binary form as 0 and the second team have the i th bit in binary form as 1. Then since any two different players have at least one different bit, they play with each other at least once.