Lim Li loves anime, and has recently bought a complete season of Umaru from Amazon. The N episodes of Umaru comes in a set of N CDs, with one episode in each CD. The CDs are labelled 1, . . . , N, and the episodes of Umaru are also numbered 1, . . . , N. She was prepared to begin watching, when she realised that due to a manufacturing fault, the episode numbers don’t match up with the labels on the CDs!
She immediately contacts Amazon, and is informed that although the CD labels do not match up with the episode numbers, the episodes are merely shuffled and no single episode is missing from the set. Wishing to avoid spoilers,
Lim Li is unwilling to play the CDs herself to figure out which episode lies in each CD. Lim Li thus decides to engage the help of her friend, Rar the Cat. The procedure she will follow is as follows:
This procedure can be done a maximum of Q times, before Rar gets annoyed and stops helping her. Help Lim Li figure out the episode numbers in each CD with minimal help from Rar.
Suppose N = 6, B = 3, K = 2, Q = 100, and the testcase belongs to Subtask 2. The episodes are [3, 1, 4, 5, 2, 6]. Your function will be called with the following parameters:
solve(6, 3, 2, 100, 2)A possible interaction could be as follows:
shuffle([[1, 2], [3, 4], [5, 6]]) = [[6, 2], [5, 4], [3, 1]]shuffle([[2, 6], [3, 1], [5, 4]]) = [[6, 1], [2, 5], [4, 3]]shuffle([[6, 5], [4, 2], [3, 1]]) = [[5, 1], [3, 4], [2, 6]]At this point, your program decides that it has enough information and concludes that the episodes are [3, 4, 1, 5, 2, 6]. As such, your program will return [3, 4, 1, 5, 2, 6]. As the episodes are correct, and the program has used less than 100 queries, it would be deemed as correct for this testcase.