Staring Contest

시간 제한1초메모리 제한1024 MB

요약
두 선수의 대결 결과가 두 값의 최솟값으로 주어질 때, 최댓값 하나는 과소평가해도 되므로 나머지 값을 모두 알아낸다.
난이도

어려움10점 중 8점

유형
정렬, 분할 정복, 완전 탐색, 구현
정답자
아직 제출이 없습니다

문제

A staring contest is a classical battle of imperturbability in which two people stare into each other's eyes while maintaining a facial expression of assured serenity. The goal is to maintain eye contact for longer than your opponent. The contest ends when one participant breaks composure, typically by looking away, smiling, speaking, or giggling.

As a coach of the national staring contest you need to determine the imperturbability of each of your team's nn members for the upcoming world finals. The iith athlete can maintain eye contact for exactly a_ia\_i seconds, but these values are unknown to you in the beginning. For instance, you could have a team of n=3n=3 members:

iiNamea_ia\_i
1Anna431
2Esther623
3Tony121

When athletes ii and jj compete, the confrontation lasts exactly min⁡(a_i,a_j)\min(a\_i, a\_j) seconds, at which moment the weaker contestant breaks composure and both contestants start smiling and giggling within a fraction of a second. For instance, if Anna competes against Esther, the contest lasts for 431431 seconds. Importantly, to an outside observer the actual winner of the confrontation (in this case, Esther) is impossible to determine, only the duration of the contest is measurable.

Your goal is to estimate the values a_1,…,a_na\_1,\ldots, a\_n using as few staring contests as possible. Clearly, the strength of the strongest athlete can never be determined, so you are allowed to underestimate one of the a_ia\_i.

제한

The number nn of athletes satisfies 2≤n≤15002\leq n\leq 1500. The imperturbability a_ia\_i of each athlete satisfies 1≤a_i≤86,4001\leq a\_i\leq 86\\,400, they are all different. You can use at most 30003000 queries; your final line of output, i.e., the line starting with !, is not counted as a query.

예제1

  1. 예제 1

    입력
    3
    
    431
    
    121
    
    121
    
    
    예상 출력
    
    ? 1 2
    
    ? 1 3
    
    ? 3 2
    
    ! 431 431 121