#P11223. [COTS 2019] 传话游戏 Pokvareni

    ID: 12475 远端评测题 1000ms 500MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2019Special Judge构造COCI(克罗地亚)

[COTS 2019] 传话游戏 Pokvareni

Background

Translated from Izborne Pripreme 2019 (Croatian IOI/CEOI Team Selection) D1T3。1s,0.5G\texttt{1s,0.5G}

Problem Description

Hint: The problem setter provides a brief summary of the task at the end of the statement.

A teacher is playing a broken telephone game with NN children. They all know the same MM words, which we label as 1M1 \sim M.

The game works like this:

  • The children stand in a line.
  • The teacher whispers word 11 to the first child.
  • For 1i<N1 \le i \lt N, the ii-th child whispers the word he heard to the (i+1)(i+1)-th child.
  • The NN-th child says out loud the word he heard.

Because there were OIers nearby typing loudly on keyboards, the game was disturbed, and the children often misheard words. However, magically, for the ii-th child, no matter who whispers to him and no matter where he is in the line, if he is whispered the same word AA, he will always hear the same word BB (it is possible that A=BA = B).

The teacher repeated the game for N!N! rounds, trying every possible permutation once. She noticed that there is a word that was said out loud exactly KK times. She is curious, so she asks you to recreate such a situation.

More specifically, given integers N,KN, K, construct positive integers M,XM, X, and a way that the children mishear words, such that among the N!N! rounds, XX is said out loud exactly KK times.

The smaller the MM you find, the higher your score. See 【Scoring】 for details.

Simply put: Given N,KN, K. Construct NN functions f1(x),f2(x),,fN(x)f_1(x), f_2(x), \ldots, f_{N}(x) from [1,M][1,M] to [1,M][1,M] (where MM is a positive integer you choose), such that:

  • Let p1,p2,,pNp_1, p_2, \ldots, p_N range over all N!N! permutations of 1N1 \sim N.
    • Put into a multiset SS the value of $f_{p_N}(f_{p_{N-1}}\cdots(f_{p_2}(f_{p_1}(1)))\cdots)$ for each of the N!N! permutations pp. Then there exists some XSX \in S such that XX appears exactly KK times in SS.

Here, [1,M][1,M] means [1,M]Z[1,M]\cap \mathbb{Z}.

The goal is to make MM as small as possible.

Input Format

This problem contains multiple testdata cases within a single test point.

The first line contains a positive integer id\mathrm{id}, which indicates the subtask number.

The second line contains a positive integer TT, the number of testdata cases.

The next TT lines each contain two integers N,KN, K, describing one test case.

Output Format

For each test case, output (N+1)(N+1) lines:

The first line contains two positive integers M,XM, X. You must ensure 1XM1041\le X\le M\le 10^4.

The next NN lines each contain MM positive integers.

In the ii-th line, the jj-th positive integer fi(j)f_{i}(j) means: if you whisper jj to the ii-th child, he will hear fi(j)f_{i}(j). You must ensure fi(j)[1,M]f_i(j)\in [1,M].

1
2
3 2
2 1
3 3
2 1 3
3 2 2
1 3 2
2 1
1 1
2 2
2
2
3 3
4 0
6 2
1 2 3 4 5 6
6 5 4 3 2 1
2 4 1 4 3 2
2 2
1 1
1 1
1 1
1 1

Hint

For 100%100\% of the data, it is guaranteed that:

  • id{1,2}\mathrm{id}\in \{1,2\}.
  • 1N121\le N\le 12.
  • 0KN!0\le K\le N!.
  • 1T101\le T\le 10.

【Scoring】

This problem is scored with two subtasks.

  • Subtask 11 (3030 pts): 1N71\le N\le 7.

    As long as your construction is valid, you get full points. Otherwise, you get 00 points.

  • Subtask 22 (7070 pts): 1N121\le N\le 12.

    If your output is invalid, you get 00 points.

    Otherwise, the score for one test case is 70k70\cdot k, where kk is computed as follows:

    $$k= \begin{cases} \displaystyle 1, & M\le N+1 \\ \displaystyle 0.7 + \frac{0.15}{M-N-1}\, \in [0.7,0.85], & N+1\lt M\le N+5 \\ \displaystyle 0.5 + 0.05 \left(5-\frac{M}{N}\right) \, \in[0.5,0.7], & N+5\lt M\le 5\cdot N \\ \displaystyle \frac{0.5}{\log_{10}(M/5N)+1}\, \in [0,0.5]& 5\cdot N\lt M\le 10^4 \\ \end{cases}$$

    The score for a single test point is the minimum score among all testdata cases. For example, in Sample 22, the two test cases have kk values 0.770.77 and 11. This output gets 0.7700.7\cdot 70 points.

Translated by ChatGPT 5