#P8126. Interactive Museum Exhibit Ranking
Interactive Museum Exhibit Ranking
Interactive Museum Exhibit Ranking
You are tasked with determining the ranking of N museum exhibits by their artistic value. You are allowed to visit the museum at most V times. During each visit, you can perform several pairwise comparisons between exhibits. In each comparison, you select a pair of exhibits \( (i,j) \) and discover which one has a higher artistic value. However, due to your past, the museum might swap the exhibits in the selected pair, thereby reversing the actual comparison result. Furthermore, the final ranking for each exhibit is determined by the result of its last comparison during the visits.
Your solution must implement the function
[ \texttt{void solve(int N, int V)} ]
Within \( \texttt{solve} \), you are allowed to call the following functions:
void schedule(int i, int j)
: Schedule a pairwise comparison between exhibits \( i \) and \( j \). (Note that the museum might swap the exhibits.)vector<int> visit()
: Finalize the current visit. This function returns a vector of results corresponding to the scheduled comparisons (in the order they were scheduled). For each compared pair \( (i,j) \), if exhibit \( i \) is determined to be of higher artistic value than exhibit \( j \) then the result is 1; otherwise, the result is 0.void answer(vector<int> r)
: Submit your final answer. Here \( r \) is a permutation of \( \{1,2,\dots,N\} \) where \( r_i = p \) signifies that exhibit \( i \) is ranked \( p \) in terms of artistic value.
Rules:
- During each visit, every exhibit can be scheduled for comparison at most once.
- The total number of visits (i.e. calls to
visit()
) must not exceed \( V \). - If any rule is violated or if
answer()
is called at an improper time, your program will immediately be terminated and judged as Not correct.
The interactive judge will respond with one of the following messages:
Message | Meaning |
---|---|
Not correct | A rule was violated or the submission was invalid |
Correct: v visit(s) used. | Your submission adhered to all constraints and was correct |
Note: For the purpose of testing, you may assume a scenario where the actual ordering of exhibits is the identity permutation \( [1, 2, \dots, N] \). In such a case, a valid (but trivial) strategy is to simply output this identity permutation.
inputFormat
The input consists of a single line containing two integers N and V, separated by a space. Here, N is the number of exhibits and V is the maximum number of visits allowed.
outputFormat
This is an interactive problem. Normally, your program should not produce any output directly. Instead, it should eventually call the function answer()
to submit a permutation of \( [1, 2, \dots, N] \) representing the ranking of the exhibits. For simulation purposes, if you choose a trivial strategy, you may simply output the identity permutation (i.e. 1 2 ... N) as the final answer.
sample
3 1
1 2 3