CF1008E.Guess two numbers

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

This is an interactive problem.

Vasya and Vitya play a game. Vasya thought of two integers aa and bb from 11 to nn and Vitya tries to guess them. Each round he tells Vasya two numbers xx and yy from 11 to nn . If both x=ax=a and y=by=b then Vitya wins. Else Vasya must say one of the three phrases:

  1. xx is less than aa ;
  2. yy is less than bb ;
  3. xx is greater than aa or yy is greater than bb .

Vasya can't lie, but if multiple phrases are true, he may choose any of them. For example, if Vasya thought of numbers 22 and 44 , then he answers with the phrase 33 to a query (3,4)(3, 4) , and he can answer with the phrase 11 or phrase 33 to a query (1,5)(1, 5) .

Help Vitya win in no more than 600600 rounds.

输入格式

The first line contains a single integer nn ( 1n10181 \leq n \leq 10^{18} ) — the upper limit of the numbers.

输出格式

First, you need to read the number nn , after that you can make queries.

To make a query, print two integers: xx and yy ( 1x,yn1 \leq x, y \leq n ), then flush the output.

After each query, read a single integer ansans ( 0ans30 \leq ans \leq 3 ).

If ans>0ans > 0 , then it is the number of the phrase said by Vasya.

If ans=0ans = 0 , it means that you win and your program should terminate.

If you make more than 600600 queries or make an incorrect query, you will get Wrong Answer.

Your solution will get Idleness Limit Exceeded, if you don't print anything or forget to flush the output.

To flush you need to do the following right after printing a query and a line end:

  • fflush(stdout) in C++;
  • System.out.flush() in Java;
  • stdout.flush() in Python;
  • flush(output) in Pascal;
  • For other languages see documentation.

Hacks format

For hacks, use the following format:

In the first line, print a single integer nn ( 1n10181 \leq n \leq 10^{18} ) — the upper limit of the numbers.

In the second line, print two integers aa and bb ( 1a,bn1 \leq a, b \leq n ) — the numbers which Vasya thought of.

In the third line, print a single integer mm ( 1m1051 \leq m \leq 10^5 ) — the number of instructions for the interactor.

In each of the next mm lines, print five integers: xix_i , yiy_i , ri12r^{12}_i , ri13r^{13}_i , and ri23r^{23}_i ( 1xi,yin1 \leq x_i, y_i \leq n ), where riSTr^{ST}_i equals to either number SS or number TT .

While answering the query xyx\,\, y , the interactor finds a number ii from 11 to nn with the minimal value xxi+yyi|x-x_i| + |y-y_i| . If multiple numbers can be chosen, the least ii is preferred. Then the interactor answers to the query, but if there are two phrases SS and TT that can be given, then riSTr^{ST}_i is chosen.

For example, the sample test data file contains the following:

<br></br>5<br></br>2 4<br></br>2<br></br>2 5 1 1 2<br></br>4 1 2 3 3<br></br>

输入输出样例

  • 输入#1

    5
    3
    3
    2
    1
    0

    输出#1

    4 3
    3 4
    3 3
    1 5
    2 4

说明/提示

Let's analyze the sample test. The chosen numbers are 22 and 44 . The interactor was given two instructions.

For the query (4,3)(4, 3) , it can return 22 or 33 . Out of the two instructions the second one is chosen, so the interactor returns a223=3a^{23}_2=3 .

For the query (3,4)(3, 4) , it can return only 33 .

For the query (3,3)(3, 3) , it can return 22 or 33 . Out of the two instructions the first one is chosen (since in case of equal values, the least number is preferred), so the interactor returns a123=2a^{23}_1=2 .

For the query (1,5)(1, 5) , it can return 11 or 33 . Out of the two instructions the first one is chosen, so the interactor returns a113=1a^{13}_1=1 .

In the fifth query (2,4)(2, 4) , the numbers are guessed correctly, the player wins.

首页