CF1619F.Let's Play the Hat?

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The Hat is a game of speedy explanation/guessing words (similar to Alias). It's fun. Try it! In this problem, we are talking about a variant of the game when the players are sitting at the table and everyone plays individually (i.e. not teams, but individual gamers play).

nn people gathered in a room with mm tables (n≥2mn \ge 2m). They want to play the Hat kk times. Thus, kk games will be played at each table. Each player will play in kk games.

To do this, they are distributed among the tables for each game. During each game, one player plays at exactly one table. A player can play at different tables.

Players want to have the most "fair" schedule of games. For this reason, they are looking for a schedule (table distribution for each game) such that:

  • At any table in each game there are either ⌊nm⌋\lfloor\frac{n}{m}\rfloor people or ⌈nm⌉\lceil\frac{n}{m}\rceil people (that is, either n/mn/m rounded down, or n/mn/m rounded up). Different numbers of people can play different games at the same table.
  • Let's calculate for each player the value bib_i — the number of times the ii-th player played at a table with ⌈nm⌉\lceil\frac{n}{m}\rceil persons (n/mn/m rounded up). Any two values of bib_imust differ by no more than 11. In other words, for any two players ii and jj, it must be true ∣bi−bj∣≤1|b_i - b_j| \le 1.

For example, if n=5n=5, m=2m=2 and k=2k=2, then at the request of the first item either two players or three players should play at each table. Consider the following schedules:

  • First game: 1,2,31, 2, 3 are played at the first table, and 4,54, 5 at the second one. The second game: at the first table they play 5,15, 1, and at the second — 2,3,42, 3, 4. This schedule is not "fair" since b2=2b_2=2 (the second player played twice at a big table) and b5=0b_5=0 (the fifth player did not play at a big table).
  • First game: 1,2,31, 2, 3 are played at the first table, and 4,54, 5 at the second one. The second game: at the first table they play 4,5,24, 5, 2, and at the second one — 1,31, 3. This schedule is "fair": b=[1,2,1,1,1]b=[1,2,1,1,1] (any two values of bib_i differ by no more than 11).

Find any "fair" game schedule for nn people if they play on the mm tables of kk games.

《帽子》是一款快速描述/猜词游戏(类似于“阿利斯”)。它很有趣,快去试试吧!在本题中,我们讨论的是该游戏的一种变体:玩家围坐在桌旁,各自独立进行游戏(即不组队,而是每位玩家单独参与)。

共有 nn 人聚集在一间屋内,屋中有 mm 张桌子(满足 n≥2mn \ge 2m)。他们希望共进行 kk 轮《帽子》游戏。因此,每张桌子上将进行 kk 局游戏,且每位玩家恰好参与 kk 局游戏。

为此,需为每局游戏分别安排玩家到各张桌子的分配方案。在每一局游戏中,每位玩家恰好坐在一张桌子上(即每局每人只在一张桌子上游戏),但同一玩家可在不同局中坐在不同的桌子上。

玩家们希望制定尽可能“公平”的游戏日程表。因此,他们寻求一种日程安排(即每局游戏对应的桌子分配方案),使得:

  • 在每一局游戏中,每张桌子上的人数要么是 ⌊nm⌋\lfloor\frac{n}{m}\rfloor,要么是 ⌈nm⌉\lceil\frac{n}{m}\rceil(即 n/mn/m 向下取整或向上取整)。同一张桌子在不同局中可容纳不同数量的玩家。
  • 对每位玩家 ii,定义 bib_i 为其在人数为 ⌈nm⌉\lceil\frac{n}{m}\rceil(即 n/mn/m 向上取整)的桌子上的游戏局数。任意两个 bib_i 的值之差至多为 11。换言之,对任意两位玩家 ii 和 jj,必须满足 ∣bi−bj∣≤1|b_i - b_j| \le 1。

例如,当 n=5n=5、m=2m=2、k=2k=2 时,根据第一条要求,每张桌子在每局游戏中应有 22 人或 33 人。考虑如下两种安排:

  • 第一局:玩家 1,2,31, 2, 3 在第一张桌子,玩家 4,54, 5 在第二张桌子;第二局:玩家 5,15, 1 在第一张桌子,玩家 2,3,42, 3, 4 在第二张桌子。该安排不公平,因为 b2=2b_2 = 2(第 22 位玩家在“大桌”(即 33 人桌)上玩了 22 次),而 b5=0b_5 = 0(第 55 位玩家从未在“大桌”上游戏)。
  • 第一局:玩家 1,2,31, 2, 3 在第一张桌子,玩家 4,54, 5 在第二张桌子;第二局:玩家 4,5,24, 5, 2 在第一张桌子,玩家 1,31, 3 在第二张桌子。该安排公平:b=[1,2,1,1,1]b = [1,2,1,1,1](任意两个 bib_i 值之差均不超过 11)。

请为 nn 位玩家、mm 张桌子、共进行 kk 局游戏的情形,构造出任意一个“公平”的游戏日程表。

输入格式

The first line of the input contains an integer tt (1≤t≤1041 \le t \le 10^4) — the number of test cases in the test.

Each test case consists of one line that contains three integers nn, mm and kk (2≤n≤2⋅1052 \le n \le 2\cdot10^5, 1≤m≤⌊n2⌋1 \le m \le \lfloor\frac{n}{2}\rfloor, 1≤k≤1051 \le k \le 10^5) — the number of people, tables and games, respectively.

It is guaranteed that the sum of nknk (nn multiplied by kk) over all test cases does not exceed 2⋅1052\cdot10^5.

输入的第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4)—— 表示测试用例的数量。

每个测试用例由一行组成,该行包含三个整数 nn、mm 和 kk(2≤n≤2⋅1052 \le n \le 2\cdot10^5,1≤m≤⌊n2⌋1 \le m \le \lfloor\frac{n}{2}\rfloor,1≤k≤1051 \le k \le 10^5)—— 分别表示人数、桌子数和游戏数。

保证所有测试用例中 nknk(即 nn 与 kk 的乘积)的总和不超过 2⋅1052\cdot10^5。

输出格式

For each test case print a required schedule — a sequence of kk blocks of mm lines. Each block corresponds to one game, a line in a block corresponds to one table. In each line print the number of players at the table and the indices of the players (numbers from 11 to nn) who should play at this table.

If there are several required schedules, then output any of them. We can show that a valid solution always exists.

You can output additional blank lines to separate responses to different sets of inputs.

对每个测试用例,输出一个所需的赛程安排——即由 kk 个块组成的序列,每个块包含 mm 行。每个块对应一场比赛,块中的一行对应一张桌子。在每一行中,首先输出该桌子上的玩家人数,然后输出应在此桌子进行比赛的玩家编号(编号范围为 11 到 nn)。

若存在多个满足要求的赛程安排,则输出任意一个即可。可以证明,合法解一定存在。

你可以在不同输入组的输出之间添加额外的空行以作分隔。

输入输出样例

  • 输入#1

    3
    5 2 2
    8 3 1
    2 1 3

    输出#1

    3 1 2 3
    2 4 5
    3 4 5 2
    2 1 3
    
    2 6 2
    3 3 5 1
    3 4 7 8
    
    2 2 1
    2 2 1
    2 2 1

输入解题思路,AI测评打分。不知道怎么写?

首页