#P11884. Ramen Delight Optimization

    ID: 13987 Type: Default 1000ms 256MiB

Ramen Delight Optimization

Ramen Delight Optimization

This is a functional and interactive problem.

There are (n) people (numbered (0) to (n-1)) and (n) types of ramen (numbered (0) to (n-1)). For each person (i) and ramen type (j), an integer (A_{i,j}) represents the liking of person (i) for ramen (j) (a higher value means a higher preference). It is guaranteed that for every person (i) and any two different ramen types (p) and (q) (with (0 \le p < q \le n-1)), (A_{i,p} \neq A_{i,q}). Note that (A_{i,j}) may be negative.

The ordering process is as follows. Given a permutation (\pi = (\pi_0, \pi_1, \ldots, \pi_{n-1})) of ({0,1,\ldots, n-1}), the first person (\pi_0) chooses her most preferred ramen. Then, the second person (\pi_1) chooses her most preferred ramen from those not taken by (\pi_0), and so on. In general, person (\pi_i) chooses her favorite ramen among those that have not been selected by (\pi_0, \pi_1, \ldots, \pi_{i-1}).

For a permutation (\pi), let (\sigma(i)) be the ramen chosen by person (i) under this process. The total delight is defined as: [ \text{Delight}(\pi)= \sum_{i=0}^{n-1} A_{i,\sigma(i)}. ]

You are allowed to make at most 750 queries. In each query, you submit a permutation (\pi), and the interactor returns (n) pairs ((\sigma(i), A_{i,\sigma(i)})) for (i=0,1,\ldots,n-1).

Your goal is to design an algorithm to output an ordering (\pi) that maximizes the total delight.

You need to implement the following function (do not implement the main function):

[ std::vector find_order(int n) ]

where:

  • (n) denotes the number of people (and ramen types).
  • The function should return a permutation (\pi_0, \pi_1, \ldots, \pi_{n-1}).

You can also call the following function (provided by the interactor):

[ std::vector<std::pair<int, int>> query(const std::vector& order) ]

which accepts a permutation (\pi) and returns (n) pairs ((\sigma(i), A_{i,\sigma(i)})), where (\sigma(i)) is the type of ramen chosen by person (i) in the given ordering and (A_{i,\sigma(i)}) is her liking value.

inputFormat

An integer (n) which is the number of people (and ramen types).

outputFormat

A permutation of ({0, 1, \ldots, n-1}) indicating the order in which people will choose their ramen.

sample

1
0