CF1179E.Alesya and Discrete Math

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

We call a function good if its domain of definition is some set of integers and if in case it's defined in xx and x1x-1 , f(x)=f(x1)+1f(x) = f(x-1) + 1 or f(x)=f(x1)f(x) = f(x-1) .

Tanya has found nn good functions f1,,fnf_{1}, \ldots, f_{n} , which are defined on all integers from 00 to 101810^{18} and fi(0)=0f_i(0) = 0 and fi(1018)=Lf_i(10^{18}) = L for all ii from 11 to nn . It's an notorious coincidence that nn is a divisor of LL .

She suggests Alesya a game. Using one question Alesya can ask Tanya a value of any single function in any single point. To win Alesya must choose integers lil_{i} and rir_{i} ( 0liri10180 \leq l_{i} \leq r_{i} \leq 10^{18} ), such that fi(ri)fi(li)Lnf_{i}(r_{i}) - f_{i}(l_{i}) \geq \frac{L}{n} (here fi(x)f_i(x) means the value of ii -th function at point xx ) for all ii such that 1in1 \leq i \leq n so that for any pair of two functions their segments [li,ri][l_i, r_i] don't intersect (but may have one common point).

Unfortunately, Tanya doesn't allow to make more than 21052 \cdot 10^{5} questions. Help Alesya to win!

It can be proved that it's always possible to choose [li,ri][l_i, r_i] which satisfy the conditions described above.

It's guaranteed, that Tanya doesn't change functions during the game, i.e. interactor is not adaptive

输入格式

The first line contains two integers nn and LL ( 1n10001 \leq n \leq 1000 , 1L10181 \leq L \leq 10^{18} , nn is a divisor of LL ) — number of functions and their value in 101810^{18} .

输出格式

When you've found needed li,ril_i, r_i , print "!""!" without quotes on a separate line and then nn lines, ii -th from them should contain two integers lil_i , rir_i divided by space.

Interaction

To ask fi(x)f_i(x) , print symbol "?" without quotes and then two integers ii and xx ( 1in1 \leq i \leq n , 0x10180 \leq x \leq 10^{18} ). Note, you must flush your output to get a response.

After that, you should read an integer which is a value of ii -th function in point xx .

You're allowed not more than 21052 \cdot 10^5 questions.

To flush you can use (just after printing an integer and end-of-line):

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

Hacks:

Only tests where 1L20001 \leq L \leq 2000 are allowed for hacks, for a hack set a test using following format:

The first line should contain two integers nn and LL ( 1n10001 \leq n \leq 1000 , 1L20001 \leq L \leq 2000 , nn is a divisor of LL ) — number of functions and their value in 101810^{18} .

Each of nn following lines should contain LL numbers l1l_1 , l2l_2 , ... , lLl_L ( 0lj<10180 \leq l_j < 10^{18} for all 1jL1 \leq j \leq L and lj<lj+1l_j < l_{j+1} for all 1<jL1 < j \leq L ), in ii -th of them ljl_j means that fi(lj)<fi(lj+1)f_i(l_j) < f_i(l_j + 1) .

输入输出样例

  • 输入#1

    5 5
    ? 1 0
    ? 1 1
    ? 2 1
    ? 2 2
    ? 3 2
    ? 3 3
    ? 4 3
    ? 4 4
    ? 5 4
    ? 5 5
    !
    0 1
    1 2
    2 3
    3 4
    4 5
    

    输出#1

    0
    1
    1
    2
    2
    3
    3
    4
    4
    4
    5
    

说明/提示

In the example Tanya has 55 same functions where f(0)=0f(0) = 0 , f(1)=1f(1) = 1 , f(2)=2f(2) = 2 , f(3)=3f(3) = 3 , f(4)=4f(4) = 4 and all remaining points have value 55 .

Alesya must choose two integers for all functions so that difference of values of a function in its points is not less than Ln\frac{L}{n} (what is 11 here) and length of intersection of segments is zero.

One possible way is to choose pairs [0[0 , 1]1] , [1[1 , 2]2] , [2[2 , 3]3] , [3[3 , 4]4] and [4[4 , 5]5] for functions 11 , 22 , 33 , 44 and 55 respectively.

首页