#P7329. 「MCOI-07」Dream and More Discs
「MCOI-07」Dream and More Discs
Description
Dream divides all of Tommy's music discs into categories. In the -th category, there are music discs. Each disc has a unique positive integer importance value.
Now Dream has sorted the discs within each category in increasing order of importance. Dream wants to know which disc has the -th smallest importance among all discs.
Because there are too many music discs, Dream cannot directly give you the importance of every disc. While searching for the answer, Dream allows you to query the importance value of the disc that is the -th smallest in the -th category.
Input Format
At the beginning of the interaction, the judge inputs four positive integers , , , and on the first line, where is the maximum number of queries allowed.
For each query, the judge will reply with the importance value of the disc at the queried position.
Output Format
Your program can perform two operations:
? i j, which queries the importance of the -th smallest disc in category . The judge will reply with the importance value at this position.! i j, which reports that the globally -th smallest disc is the -th smallest disc in category .
2 2 2 22
222
? 2 2
! 2 2
Hint
Explanation for Sample 1
Dream's disc importance values are .
Category 2 is ; the 2nd smallest importance in category 2 is .
The globally 2nd smallest importance is also this disc.
Constraints
This problem uses bundled testdata.
| Subtask | Score | ||||
|---|---|---|---|---|---|
| 1 | 1 pts | ||||
| 2 | 9 pts | None | |||
| 3 | 19 pts | ||||
| 4 | 17 pts | ||||
| 5 | 23 pts | ||||
| 6 | 31 pts | ||||
For all testdata, . All disc importance values are pairwise distinct and are at most .
Translated by ChatGPT 5
京公网安备 11011102002149号