PivotOJ

The Big Prize

시간 제한: 1000ms메모리 제한: 1024MB출처: IOI 2017BOJ 20079

문제

The Big Prize is a famous TV game show. You are the lucky contestant who has advanced to the final round. You are standing in front of a row of nn boxes, labeled 00 through n1n-1 from left to right. Each box contains a prize that cannot be seen until the box is opened. There are v2v \geq 2 different types of prizes. The types are numbered from 11 to vv in decreasing order of value.

The prize of type 11 is the most expensive one: a diamond. There is exactly one diamond in the boxes. The prize of type vv is the cheapest one: a lollipop. To make the game more exciting, the number of cheaper prizes is much larger than the number of more expensive ones. More specifically, for all tt such that 2tv2 \leq t \leq v we know the following: if there are kk prizes of type t1t-1, there are strictly more than k2k^2 prizes of type tt.

Your goal is to win the diamond. At the end of the game you will have to open a box and you will receive the prize it contains. Before having to choose the box to open you get to ask Rambod, the host of the game show, some questions. For each question, you choose some box ii. As his answer, Rambod will give you an array aa containing two integers. Their meaning is as follows:

  • Among the boxes to the left of box ii there are exactly a[0]a[0] boxes that contain a more expensive prize than the one in box ii.
  • Among the boxes to the right of box ii there are exactly a[1]a[1] boxes that contain a more expensive prize than the one in box ii.

For instance, suppose that n=8n=8. For your question, you choose the box i=2i=2. As his response, Rambod tells you that a=[1,2]a=[1,2]. The meaning of this response is:

  • Exactly one of the boxes 00 and 11 contains a prize more expensive than the one in box 22.
  • Exactly two of the boxes 3,4,,73, 4, \ldots, 7 contain a prize more expensive than the one in box 22.

Your task is to find the box containing the diamond by asking a small number of questions.

코드를 제출하려면 로그인하세요.