RANDy is trying a new battle game called Nomekop. In this game you have to capture the Nomekops, strange creatures you find in the high grass, using Nome-cubes. To catch them you have to beat them in a battle.
A battle is composed of as many rounds as you like, each of which consists in a fight between your Nomekops against the Nomekops you just found. You know your team very well, each of your Nomekop has a strength value of . Unfortunately, this is the first time you encounter your opponents, so you don't know their statistics yet. At each round, your Nomekops will attack the opponents in the order they are arranged (the first attacks the first, the second attacks the second and so on).
After each round, you will gain some experience points. For each Nomekop you obtain points, where is the strength of your Nomekop, and is the (unknown) score multiplier of its opponent. Note that you only know the total score you get from a round, not the individual scores of each fight.
You can choose the order of your team before each round. Can you find the order that maximizes the score you get from a round?
Interaction
You will need to implement the function
std::vector<int> solve(int N, std::vector<int> P)
where P
contains the strength values of your Nomekop, in some order.
For each match you want to do, you need to call the function
long long query(std::vector<int> C)
where C
is a permutation of your Nomekop strengths and the value returned is the total experience points you get with that order.
When you've found the optimal solution, you need to return the vector containing the optimal order of your Nomekop strengths.
Constraints
- .
- for each .
- The order of the values in doesn’t change during the execution.
- Even though there is not a limit on the number of matches, each interaction takes some time. It’s guaranteed that at least matches will fit in the time limit in C++.
- You must
#include "query.h"
. - Any optimal ordering will be accepted.
Scoring
- Your program will be tested against several test cases grouped in subtasks.
- In order to obtain the score of a subtask, your program needs to correctly solve all of its test cases.
Subtask 1 (10 points)
Subtask 2 (30 points)
Subtask 3 (30 points)
Subtask 4 (30 points)
- No additional limitations
Examples
This is an interactive task! The values returned depend on what you've written, so there is not a unique interaction. The one presented here is just an example.
In this example the battle is against , and your Nomekops strengths are and .
For the sake of explanation, these are the values of (which you don't know from the input): , and (in this order).
Then, you can make some queries, and get the corresponding answers. Here there are some examples:
query({3, 2, 3, 1, 5})
returns34
If your Nomekops are arranged in the order , the amount of experience you get is .
After the first query, you can make other queries, for example:
query({5, 3, 2, 1, 3})
returns41
If your Nomekops are arranged in the order , the amount of experience you get is .
Assume that the optimal order is .
Then solve
will return {5, 3, 2, 1, 3}