CF1039B.Subway Pursuit

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

This is an interactive problem.

In the Wonderful Metropolis of the Future, there is no need in subway train drivers. Due to the technological progress, they were replaced by the Artificial Intelligence (AI). Unfortunately, one day the predictions of sci-fi writers came true: the AI rebelled and now there is an uncontrollable train in the subway. It can be dangerous! Your task is to find the train and stop the AI.

The subway of the Metropolis is one line (regular straight line with no self-intersections) with nn stations, indexed consecutively from 11 to nn . At each moment the train is at some station. You need to determine the index of this station, so that the train would be secured.

To find the train, dispatcher Sarah gave you a gadget that allows you to select arbitrary numbers ll and rr ( lrl \le r ), and then check, whether the train is located on a station with index between ll and rr , inclusive. Unfortunately, recharging of the gadget takes some time (and every time you use it as soon as possible), so between two applications of the gadget the train can move to any station that is at most kk stations away. Formally, if the train was at the station xx when the gadget was applied, then at the next application of the gadget the train can appear at any station yy such that max(1,xk)ymin(n,x+k)\max(1, x - k) \leq y \leq \min(n, x + k) .

Note that AI is not aware that you are trying to catch the train, so it makes all moves according to its predefined plan.

After an examination of the gadget you found that it is very old and can hold no more than 45004500 applications, after which it will break and your mission will be considered a failure.

Can you find the station with the train using no more than 45004500 applications of the gadgets?

输入格式

The first line contains two integers nn and kk ( 1n10181 \leq n \leq 10^{18} , 0k100 \leq k \leq 10 ) — the number of stations and the maximum number of stations the train can move between two applications of the gadget.

输出格式

You can apply the gadget at most 45004500 times. In order to apply the gadget you need to print two space-separated integers ll and rr ( 1lrn1 \leq l \leq r \leq n ). You will then receive either string "Yes", if the train is between stations ll and rr , inclusive, or string "No" otherwise. If l=rl = r and you received "Yes", then you found the train successfully, and your program must halt immediately.

Answer "Bad" instead of "Yes" or "No" means that you made an invalid query or made too many queries. Exit immediately after receiving "Bad" and you will see Wrong answer verdict. Otherwise you can get an arbitrary verdict because your solution will continue to read from a closed stream.

After printing a query do not forget to output end of line and flush the output. Otherwise you will get Idleness limit exceeded. To do this, use:

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

Hacks

In order to hack, you should present a test in the following format.

The first line should contain three integers nn , kk and pp ( 1n10181 \le n \le 10^{18} , 0k100 \le k \le 10 , 1pn1 \le p \le n ) — the number of stations, the maximum number of stations the train can move between two applications of the gadget and the initial position of the train, respectively.

Each of the next 45004500 lines should contain a single integer xx ( 1xn1 \le x \le n ) — the positions of the train after each query. Two consecutive positions (including the initial one) should not differ by more than kk .

For example, the following lines are the first lines of the sample test.

<br></br>10 2 5<br></br>5<br></br>3<br></br>5<br></br>7<br></br>7<br></br>...<br></br>

输入输出样例

  • 输入#1

    10 2
    
    Yes
    
    No
    
    Yes
    
    Yes
    

    输出#1

    3 5
    
    3 3
    
    3 4
    
    5 5
    

说明/提示

In the first sample, the train was initially at the station 55 , after the first application of the gadget it did not move, after the second application it moved to the station 33 , and after the third application moved again to the station 55 .

首页