DMOPC '22 Contest 1 P4 - Card Game

View as PDF

Submit solution


Points: 12 (partial)
Time limit: 5.0s
Memory limit: 256M

Author:
Problem type

You are playing a card game with an opponent. Your opponent will draw N cards and insert them into their hand one by one. Each of these cards has a value between 1 and K, chosen uniformly at random and independent of the other cards.

Having played this game many times against this opponent, you realize that they always insert these cards in a highly predictable way. For each card, your opponent inserts it into their hand so that their hand remains sorted in nondecreasing order, and this new card is inserted before all occurrences of the same value.

You carefully observe that your opponent inserted the i-th card at position b_i. That is, there were b_i cards before the position that the i-th card was inserted in when the i-th card was inserted.

From this information, can you guess the number of times each value appears in your opponent's hand? You will play T games in each file, and you only need to be correct in enough games.

Constraints

N = 100

0 \le b_i \le i-1

Each subtask contains exactly 10 test files. Every test case is generated from a sequence of N card values that are integers between 1 and K, chosen uniformly at random and independent of the other card values.

You do not need to pass any previous subtasks to be judged on a subtask.

Subtask 1 [15%]

K = 2

T = 10^3

Subtask 2 [25%]

K = 5

T = 10^4

Subtask 3 [60%]

K = 10

T = 10^5

You do not have to correctly answer all T test cases to get full points in this subtask. Please check the Scoring section for more details.

Input Specification

The first line contains 3 space-separated integers: N, K, and T.

The next T lines each contain N space-separated integers: The positions b_i in a single test case.

Output Specification

Output T lines, each containing K space-separated integers. The i-th integer on a line should represent the number of times you guess that a card with value i appears in your opponent's hand in that test case.

Scoring

For each test file:

If you do not output exactly T lines, each containing K space-separated integers between -10^9 and 10^9, you will receive a score of 0 for that file and a Wrong Answer verdict.

Otherwise, each of the T test cases will be graded as correct if the sequence you produced exactly matches the sequence of card frequencies that was generated. Your score for the test file is determined as follows:

  • In subtasks 1 and 2, you will receive full points if you answer 100\% of the cases correctly and 0 points otherwise. You will receive a Wrong Answer verdict if you did not answer 100\% of the cases correctly.
  • In subtask 3, suppose you answered Q of the cases correctly. Your score will be calculated as:

\displaystyle \left\lfloor 60 \cdot \sqrt{\frac{Q}{0.997T}} \right\rfloor

In particular, you will receive full points if you answer at least 99.7\% of the cases correctly.

Your final score within a subtask will be the minimum score over all 10 test files.

Sample Input

5 3 2
0 1 2 1 3
0 0 0 0 0

Sample Output

1 2 2
3 0 2

Explanation

This sample input does not satisfy the constraints for any subtask and is only provided to clarify the input and output format.

In the first case, it is possible to uniquely determine that the sequence of N card values was [1,2,3,2,3], so the card counts are [1,2,2].

In the second case, one possible sequence of N card values is [3,3,1,1,1], giving card counts of [3,0,2]. Note that we cannot uniquely determine the card counts; for example, [3,2,2,2,1] giving card counts of [1,3,1] is also possible. This case will be graded as correct only if you correctly guessed the exact card frequencies that were generated, so [3,0,2] is a reasonable guess.


Comments

There are no comments at the moment.