Logo
(追記) (追記ここまで)

32794번 - Homework Help 다국어인터랙티브

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB14131392.857%

문제

Alice was recently given a homework assignment to write a program that would output the number of inversions in any subarray of a given permutation. She happily turned it in and got full marks on her assignment. The next week, their homework assignment was to find the length of the longest increasing subsequences in the same array. Unfortunately, Alice had already thrown away the paper that contained the permutation she needed.

Luckily, this permutation was stored in the program she wrote. Unfortunately, she is now only able to query for the number of inversions in the subarrays of the permutation. As class is close to starting, she asks you for help to solve this problem in a timely manner.

A sequence $a$ is a subsequence of an array $b$ if it is possible to delete some (possibly zero) elements from $b$ to get $a$. A sequence is increasing if every element is strictly greater than all preceding ones, and the LLIS of an array is the length of the longest increasing subsequence.

인터랙션

This is an interactive problem.

Interaction starts by reading a single integer $n$ (1ドル \le n \le 10^3$), the length of the permutation $p$.

You are then able to make at most $n$ queries of the form ? l r where 1ドル \le l \le r \le n$. Each query should be on a single line. After each query, read in a single integer, the number of inversions in the subarray $[l, r]$. An inversion is a pair of integers $(x, y)$ where $l \le x < y \le r$ and $p_x > p_y$.

When you have determined the LLIS, output the answer in the form: ! ans on a single line, where ans is the LLIS. After outputting the answer, your program should exit. If you attempt to read a response after outputting an answer, you will receive an arbitrary verdict.

Do not forget to flush the output after each query you output.

The interactor is not adaptive: When the interaction begins, the permutation $p$ is already determined. It is guaranteed that each integer from 1ドル$ to $n$ appears exactly once.

If the interactor receives any invalid or unexpected input, the interactor will output $-1$ and then immediately terminate. Your program should cleanly exit in order to receive a Wrong Answer verdict, otherwise the verdict that it receives may be an arbitrary verdict indicating that your submission is incorrect.

If your program terminates before outputting the answer, your submission will receive an arbitrary verdict indicating that your submission is incorrect.

You are provided with a command-line tool for local testing. The tool has comments at the top to explain its use.

입력

출력

제한

예제 입력 1

3
1
1

예제 출력 1

? 1 3
? 1 2
! 2

힌트

첨부

출처

ICPC > Regionals > North America > Pacific Northwest Regional > 2024 ICPC Pacific Northwest Regional > Division 1 H번

ICPC > Regionals > North America > Pacific Northwest Regional > 2024 ICPC Pacific Northwest Regional > Division 2 J번

  • 문제를 만든 사람: Jerry Li

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /