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

32974번 - Procesor 점수다국어인터랙티브

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

문제

Initially, Fran has an empty array $a$. Fran processes $n$ queries of the form $x$ — he appends $x$ elements to the end of $a$. After each query, Fran wants to determine the smallest element in the array $a,ドル and once he identifies it, he removes it from the array without altering the indices of the other elements.

Your task is to determine the smallest element of the array for each query by asking questions.

인터랙션

This is an interactive task. Your goal is to write a program that responds to the queries.

The input begins with a single line containing $n$ — the number of queries (1ドル ≤ n ≤ 40$). Then, $n$ queries follow, each starting with $x_i$ — the number of elements added to the array (1ドル ≤ x_i ≤ 2000$).

After each query, your program may ask questions of the form ? $i$ $j$. The interactor will respond with 0ドル$ if $a_i < a_j,ドル or 1ドル$ if $a_i > a_j$. You may assume all elements in the array are distinct. $i \ne j$ must hold, and indices $i$ and $j$ must not correspond to already removed elements.

After determining the smallest element, you must print ! $x,ドル which indicates that $a_x$ is the smallest element in the array $a$ (excluding already removed elements). The index $x$ must not correspond to an already removed element.

You may ask questions multiple times, and after printing the smallest element, the next query begins.

Once you determine the smallest element, the interaction continues with subsequent queries. After the last query, the interaction ends, and your solution is evaluated based on the number of questions asked.

The total length of the array will not exceed 2000ドル$.

입력

출력

제한

점수

Your program will earn points based on the number of questions asked. Let $q$ be the total number of questions your program asked.

  • If $q ≤ 2700,ドル your program will earn 120ドル$ points.
  • If 2700ドル < q ≤ 7000,ドル your program will earn 75ドル$ points.
  • If 7000ドル < q ≤ 2 \cdot 10^4,ドル your program will earn 35ドル$ points.
  • If 2ドル · 10^4 < q ≤ 8 \cdot 10^4,ドル your program will earn 15ドル$ points.

예제 입력 1

3
3
1
0
0
1
1
1
0

예제 출력 1

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

힌트

Explanation of the Sample Case:

The final array is of the form 3,ドル 2, 4, 1, 5$.

The first query outputs 1ドル$ because $a_1 > a_2$.

The second query outputs 0ドル$ because $a_1 < a_3$.

The third query outputs 0ドル$ because $a_2 < a_3$.

After this, it can be determined that $a_2$ is the smallest current element, so the output is ! 2ドル$. The interaction continues with the subsequent queries.

출처

Contest > Croatian Open Competition in Informatics > COCI 2024/2025 > Contest #3 5번

채점 및 기타 정보

  • 120점 이상을 획득해야 를 받는다.
  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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