#P15953. [ICPC 2018 Jakarta R] Smart Thief

[ICPC 2018 Jakarta R] Smart Thief

题目描述

Ayu managed to steal Budi's treasure box and ready to uncover any secret Budi hides. Unfortunately, the treasure box has some security system to prevent any unauthorized person (e.g., Ayu) from opening it.

To unlock the treasure box, Ayu has to input a correct PIN (Personal Identification Number) of length NN, which of course, she doesn't have. Ayu has no choice other than trying all possible PIN combinations. However, Ayu notices that this security system has an interesting (old) mechanism.

When you enter an NN digits PIN, it is evaluated automatically and promptly, i.e. you don’t need to push some “enter” button to confirm the PIN. Whenever your entered PIN is wrong, it removes the oldest (first) digit and shifts all the remaining to the left, thus, you only need to enter one more (last) digit to make it NN length again. For example, let N=4N = 4. If we input 204320435204320435, then we actually test 66 PINs (with 55 different PINs):

  • [20432043]2043520435, tested PIN = 20432043
  • 22[04320432]04350435, tested PIN = 04320432
  • 2020[43204320]435435, tested PIN = 43204320
  • 204204[32043204]3535, tested PIN = 32043204
  • 20432043[20432043]55, tested PIN = 20432043
  • 2043220432[04350435], tested PIN = 04350435

Notice that 20432043 is tested twice in this example.

As a CS student, Ayu knows that finding the correct PIN by trying all possible combinations can be very time-consuming, but alas, there’s no other way. Ayu decides that she wants to test at least KK different PINs on the first day. Your task is to help Ayu by simply giving her the string SS which contains at least KK different PINs. Ayu doesn’t care which PIN she’s going to test (so long at least there are KK different PINs) or whether any PIN is tested more than once in SS, but string SS needs to be as short as possible. If there is more than one possible string for SS, you can output any of them.

Note that, as this system is quite old, there are only MM available digits ranging from 00 to 99.

输入格式

Input begins with a line containing three integers: N M KN\ M\ K (1N1000001 \leq N \leq 100000, 1M101 \leq M \leq 10, 1Kmin(MN,100000)1 \leq K \leq \min(M^N, 100000)), representing the PIN length, the number of available digits, and the minimum number of PINs to be tested, respectively. The next line contains MM integers: AiA_i (0Ai90 \leq A_i \leq 9), representing the available digits. You may assume all AiA_i are distinct. You may also assume that the values of NN, MM, and KK are chosen such that the answer contains no longer than 100000100000 digits.

输出格式

Output in a line the shortest string which contains at least KK different PINs as its substring. If there is more than one such string, you can output any of them.

3 2 5
4 7
7477447
2 5 9
1 2 3 4 5
1234554321
6 3 2
9 3 5
9353593

提示

Explanation for the sample input/output #1

There are 55 different PINs of length 33 tested with the string 74774477477447, i.e. 447447, 477477, 744744, 747747, and 774774.

Explanation for the sample input/output #2

There are 99 different PINs of length 22 tested with the string 12345543211234554321, i.e. 1212, 2121, 2323, 3232, 3434, 4343, 4545, 5454, and 5555.

Explanation for the sample input/output #3

There are 22 different PINs of length 66 tested with the string 93535939353593, i.e. 353593353593, and 935359935359.