시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
12.5 초 (추가 시간 없음) | 1024 MB | 75 | 34 | 26 | 41.935% |
You are a market salesman. Every week you sell your wares in a beautiful authentic market stall. People travel from faraway lands to buy your signature product: fermented shark. Of course, such a delicious product should only be exchanged for a vast amount of shining, valuable coins.
Sometimes customers try to fool you by paying with counterfeit coins. You always spot them, of course; you take out your trusty scale and weigh the coins to determine if any of them are of different weight.
In this particular instance, a rather notorious customer by the name of Peter Rog Rammer, famous for his "off-by-one errors", has just paid for a fermented shark dish using $n$ seemingly identical coins. However, you are sure that there is one coin that is not quite the same as the others. As the line of customers is getting rather lengthy, you do not want to spend too much time finding the odd one out!
This is an interactive problem. Your submission will be run against an interactor, which reads the standard output of your submission and writes to the standard input of your submission. This interaction needs to follow a specific protocol:
?
", indicating that you want to compare the $x$th and $y$th coin.lighter
" if the $x$th coin weighs less than the $y$th coin.heavier
" if the $x$th coin weighs more than the $y$th coin.equal
" if the $x$th coin weighs the same as the $y$th coin.!
" followed by a single integer $x$ ($1 \leq x \leq n$), indicating that the $x$th coin is the coin that does not weigh the same as the others.You may use at most $\lceil n/2 \rceil$ moves. Printing the answer does not count as a move.
Note that for testing purposes, the index of the counterfeit coin is not necessarily fixed at the start of the interaction, but may be set by the interactor at any point (but always in a way that is consistent with its answers to previous queries).
Make sure you flush the buffer after each write.
A testing tool is provided to help you develop your solution.
5 equal lighter heavier
? 1 5 ? 4 3 ? 2 4 ! 4
ICPC > Regionals > Europe > Northwestern European Regional Contest > NWERC 2021 PC번