시간 제한메모리 제한제출정답맞힌 사람정답 비율
30 초 (추가 시간 없음) 512 MB597750.000%

문제

You might have heard that in his free time, Mr. Malnar does magic. His recent appearance in the famous TV show Penn & Teller: Fool Us took the world by storm. He introduced himself as The Magical Mr. Malnar, pulled off an incredible mentalist trick, and swept everyone off their feet.

He started off by calling up an eager volounteer from the audience and asking them to think of any string of their choice that consists of exactly $N$ letters. He then proceeded to entertain the audience, occasionally glancing at the volounteer, and at the end he declared: “the longest sub-palindrome1 of your string has length $L$”. After the volounteer confirmed this is indeed correct, the audience was stunned.

However, observant viewers and close friends of Mr. Malnar suspect this was not mind reading, but a clever selection of words that, when combined with excellent reading of facial expressions, gives away enough information to pull off the trick.

While it seemed like Mr. Malnar was merely fooling around, from time to time he would mention some interval of numbers $[l, r]$, where $1 ≤ l ≤ r ≤ N$ and briefly glance at the volounteer. There are rumors saying he is able to determine whether or not the substring of the volounteer’s string that consists of the $l$-th through the $r$-th letter (inclusive) is a palindrome, based on their facial expression alone.

You need to write a program which will confirm that Mr. Malnar, if the rumors are true, was able to gather enough information to determine the longest sub-palindrome of the secret string choosen by the volounteer.


1A palindrome is a string that reads the same backward or forward. A substring of a string is a string made up from the $l$-th through the $r$-rh letter of that string, for some $1 ≤ l ≤ r ≤ N$. A sub-palindrome is a substring which is also a palindrome.

인터랙션

This is an interactive task. Your program must communicate with a program made by the organizers which simulates the behaviour of the volounteer from the task description.

Before interaction, your program should read an integer $N$, the length of the secret string, from the standard input task statement.

After that, your program can send query requests by writing to the standard output. Each query must be printed in a separate line and have the form “? $l$ $r$”, where $1 ≤ l ≤ r ≤ N$ holds. After each query has been written, your program should flush the output and read the answer from the standard input. The answer is a $1$ if the substring $[l, r]$ is a palindrome, or $0$ if it’s not. Your program can make at most $200\,000$ such queries.

After your program has deduced the length of the longest sub-palindrome, it should write a line to the standard output in the form “! $L$”, where $L$ is the said length. After that, your program should flush the output once more and gracefully terminate its execution.

서브태스크

번호배점제한
113

$1 ≤ N ≤ 7\,500$

225

$1 ≤ N ≤ 65\,000$

325

$1 ≤ N ≤ 100\,000$, the secret string consists of letters a and b only

437

$1 ≤ N ≤ 100\,000$

예제

Output Input Comment
5 The secret string has length $5$. In this example, the volounteer chose the string neven.
? 1 1 1 Substring n is a palindrome.
? 2 3 0 Substring ev isn’t a palindrome.
? 2 4 1 Substring eve is a palindrome.
? 3 5 0 Substring ven isn’t a palindrome.
? 1 5 1 Substring neven is a palindrome.
! 5 Correct, the longest sub-palindrome is the whole string neven.

채점 및 기타 정보

  • 예제는 채점하지 않는다.
  • 이 문제의 채점 우선 순위는 2이다.