All submissions for this problem are available.
Read problems statements in Mandarin Chinese , Russian and Vietnamese
Sergey is visiting ChefTown - a town famous for its' restaurants with famous ChefLand's cuisine. Among the most recommended things to do in ChefTown is to taste ChefLand's all N national dishes. Sergey has decided to do it, but as the person who is fond of planning everything, he needs to plan his restaurants' visit's in advance.
He knows that he will stay in ChefTown for D days and each day he'll have a dinner in one of ChefTown's restaurants. It is always hard to say, whether a particular dish will appear in the restaurant on some particular day. But based on the internet reviews, he concluded that the probability that the i-th dish will appear in the restaurant he's going to visit on the j-th day is Ai, j.
On the other hand, everything is even more complicated. Sergey is a thin guy and thus unable to eat more than K dishes in a single day. That doesn't mean that he has to eat K dishes every day, but if he won't eat any dish at all during some day, he'll go to sleep hungry and displeased, so he wants to avoid such situations. Because of hard financial situation, he will have food only in restaurants and wants to taste all the dishes exactly once.
Now, in order to process all this information, Sergey asks you to help him. Please make a plan for him such that:
- In the plan, he will taste every dish exactly once.
- During any day, he will eat at least one dish, but no more than K dishes in total. Here we mean, that he will plan to eat no more than K dishes (and at least one dish), but note that he might fail in this because of unavailability of some dishes on a particular day.
- The total probability that all the dishes will be available on their planned days of eating is maximal.
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
The first line of each test case contains single space-separated integers N, D and K denoting the number of dishes that Sergey wants to taste, the number of days he'll stay in ChefTown and the maximum number of dishes he can eat during a single day respectively.
The following N lines will contain D space-separated real numbers each, where the j-th real number in the i-th line denotes the probability that the dish numbered i-th will be available in the restaurant that he will visit during the j-th day.
For each test case, output two lines.
- The first line should contain maximal possible probability of eating all the dishes. Your answer will be considered as correct if it has an absolute error less than 1e−6 (ie. 10-6).
- The second line should contain N space-separated integers, describing the plan. The i-th integer should describe the 1-indexed number of day, during which the i-th dish will be eaten. If there are more than one such possible plans, you can print any one of them.
- 1 ≤ T ≤ 10
- 1 ≤ N ≤ 50
- 1 ≤ D, K ≤ N
- D*K ≥ N
- 0.750 ≤ Ai, j ≤ 1.000
- The probabilities will be given with no more than 3 digits after the decimal point.
Input: 1 3 3 1 1.0 1.0 0.8 0.8 1.0 1.0 0.8 0.8 0.8 Output: 0.8 1 2 3
Example case 1.On the first day, Sergey will eat the first dish. On the second day, he'll eat the second dish. On the third day, he'll try eat the third dish that will appear with the probability of 0.8. The total probability of dishes being available on these days is 0.8. It is impossible to achieve the better result.
|Tags||graphs, min-cost-flow, snck151a, xcwgf666|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.5, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.