Hide

Problem B
Staring Contest

Languages da de en fi lt lv pl uk
/problems/boi23.staringcontest/file/statement/en/img-0001.png

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 $n$ members for the upcoming world finals. The $i$th athlete can maintain eye contact for exactly $a_ i$ seconds, but these values are unknown to you in the beginning. For instance, you could have a team of $n=3$ members:

$i$

Name

$a_ i$

1

Anna

431

2

Esther

623

3

Tony

121

When athletes $i$ and $j$ compete, the confrontation lasts exactly $\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 $431$ 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,\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_ i$.

Interaction

This is an interactive problem. The interaction begins with you reading a single line containing the integer $n$. You may then ask queries of the form “? $i$ $j$” such that $1\leq i\leq n$ and $1\leq j\leq n$ and $i\neq j$. The response to a query is a single integer: the value $\min (a_ i, a_ j)$. The interaction ends with you printing a single line consisting of ! followed by $n$ estimates in the form of integers $b_1$, $\ldots $, $b_ n$, separated by spaces. This must be your final line of output.

Your submission is correct if $b_ i=a_ i$ for every contestant $i$ except one, which you may underestimate. To be precise, we require $b_ i\leq a_ i$ for all $1\leq i\leq n$ and allow $b_ k \neq a_ k$ for at most one $k$.

The interactor is non-adaptive, meaning that the $a_1,\ldots , a_ n$ are determined before the interaction begins.

Constraints and Scoring

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

Your solution will be tested on a set of test groups, each worth a number of points. Each test group contains a set of test cases. To get the points for a test group you need to solve all test cases in the test group. Your final score will be the maximum score of a single submission.

For group $3$, your score is the minimum score among all test cases in the group. The score for each test case depends on the number of queries you use; fewer queries are better: Suppose you use $q$ queries. If $q \le n+25$, then you get the full $80$ points. If $q > 3000$, then you get no points. Otherwise, you get $118.2 - 12 \cdot \ln (q - n)$ points, rounded to the nearest integer. For instance, for $n = 1500$ and $q = 3000$, you get $30$ points.

Group

Points

Constraints

$1$

$9$

$n\leq 50$

$2$

$11$

$n\leq 1000$

$3$

$0$$80$

$1000 < n\leq 1500$

Explanation of sample interactions

Sample interaction $1$ shows a possible interaction using the above example. Note that Anna’s and Tony’s strengths are correctly determined. (Esther’s can never be determined.)

Read Sample Interaction 1 Write
3
? 1 2
431
? 1 3
121
? 3 2
121
! 431 431 121