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).
n people gathered in a room with m tables (n≥2m). They want to play the Hat k times. Thus, k games will be played at each table. Each player will play in k 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 ⌊mn⌋ people or ⌈mn⌉ people (that is, either n/m rounded down, or n/m rounded up). Different numbers of people can play different games at the same table.
- Let's calculate for each player the value bi — the number of times the i-th player played at a table with ⌈mn⌉ persons (n/m rounded up). Any two values of bimust differ by no more than 1. In other words, for any two players i and j, it must be true ∣bi−bj∣≤1.
For example, if n=5, m=2 and k=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,3 are played at the first table, and 4,5 at the second one. The second game: at the first table they play 5,1, and at the second — 2,3,4. This schedule is not "fair" since b2=2 (the second player played twice at a big table) and b5=0 (the fifth player did not play at a big table).
- First game: 1,2,3 are played at the first table, and 4,5 at the second one. The second game: at the first table they play 4,5,2, and at the second one — 1,3. This schedule is "fair": b=[1,2,1,1,1] (any two values of bi differ by no more than 1).
Find any "fair" game schedule for n people if they play on the m tables of k games.
《帽子》是一款快速描述/猜词游戏(类似于“阿利斯”)。它很有趣,快去试试吧!在本题中,我们讨论的是该游戏的一种变体:玩家围坐在桌旁,各自独立进行游戏(即不组队,而是每位玩家单独参与)。
共有 n 人聚集在一间屋内,屋中有 m 张桌子(满足 n≥2m)。他们希望共进行 k 轮《帽子》游戏。因此,每张桌子上将进行 k 局游戏,且每位玩家恰好参与 k 局游戏。
为此,需为每局游戏分别安排玩家到各张桌子的分配方案。在每一局游戏中,每位玩家恰好坐在一张桌子上(即每局每人只在一张桌子上游戏),但同一玩家可在不同局中坐在不同的桌子上。
玩家们希望制定尽可能“公平”的游戏日程表。因此,他们寻求一种日程安排(即每局游戏对应的桌子分配方案),使得:
- 在每一局游戏中,每张桌子上的人数要么是 ⌊mn⌋,要么是 ⌈mn⌉(即 n/m 向下取整或向上取整)。同一张桌子在不同局中可容纳不同数量的玩家。
- 对每位玩家 i,定义 bi 为其在人数为 ⌈mn⌉(即 n/m 向上取整)的桌子上的游戏局数。任意两个 bi 的值之差至多为 1。换言之,对任意两位玩家 i 和 j,必须满足 ∣bi−bj∣≤1。
例如,当 n=5、m=2、k=2 时,根据第一条要求,每张桌子在每局游戏中应有 2 人或 3 人。考虑如下两种安排:
- 第一局:玩家 1,2,3 在第一张桌子,玩家 4,5 在第二张桌子;第二局:玩家 5,1 在第一张桌子,玩家 2,3,4 在第二张桌子。该安排不公平,因为 b2=2(第 2 位玩家在“大桌”(即 3 人桌)上玩了 2 次),而 b5=0(第 5 位玩家从未在“大桌”上游戏)。
- 第一局:玩家 1,2,3 在第一张桌子,玩家 4,5 在第二张桌子;第二局:玩家 4,5,2 在第一张桌子,玩家 1,3 在第二张桌子。该安排公平:b=[1,2,1,1,1](任意两个 bi 值之差均不超过 1)。
请为 n 位玩家、m 张桌子、共进行 k 局游戏的情形,构造出任意一个“公平”的游戏日程表。
输入格式
The first line of the input contains an integer t (1≤t≤104) — the number of test cases in the test.
Each test case consists of one line that contains three integers n, m and k (2≤n≤2⋅105, 1≤m≤⌊2n⌋, 1≤k≤105) — the number of people, tables and games, respectively.
It is guaranteed that the sum of nk (n multiplied by k) over all test cases does not exceed 2⋅105.
输入的第一行包含一个整数 t(1≤t≤104)—— 表示测试用例的数量。
每个测试用例由一行组成,该行包含三个整数 n、m 和 k(2≤n≤2⋅105,1≤m≤⌊2n⌋,1≤k≤105)—— 分别表示人数、桌子数和游戏数。
保证所有测试用例中 nk(即 n 与 k 的乘积)的总和不超过 2⋅105。
输出格式
For each test case print a required schedule — a sequence of k blocks of m 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 1 to n) 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.
对每个测试用例,输出一个所需的赛程安排——即由 k 个块组成的序列,每个块包含 m 行。每个块对应一场比赛,块中的一行对应一张桌子。在每一行中,首先输出该桌子上的玩家人数,然后输出应在此桌子进行比赛的玩家编号(编号范围为 1 到 n)。
若存在多个满足要求的赛程安排,则输出任意一个即可。可以证明,合法解一定存在。
你可以在不同输入组的输出之间添加额外的空行以作分隔。
输入输出样例
输入#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测评打分。不知道怎么写?