CF244A.Dividing Orange

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

One day Ms Swan bought an orange in a shop. The orange consisted of n·k segments, numbered with integers from 1 to n·k.

There were k children waiting for Ms Swan at home. The children have recently learned about the orange and they decided to divide it between them. For that each child took a piece of paper and wrote the number of the segment that he would like to get: the i-th (1 ≤ i ≤ k) child wrote the number a__i (1 ≤ a__i ≤ n·k). All numbers a__i accidentally turned out to be different.

Now the children wonder, how to divide the orange so as to meet these conditions:

  • each child gets exactly n orange segments;
  • the i-th child gets the segment with number a__i for sure;
  • no segment goes to two children simultaneously.

Help the children, divide the orange and fulfill the requirements, described above.

一天,斯旺女士在商店买了一个橙子。这个橙子由 n⋅kn \cdot k 个瓣组成,编号为从 11 到 n⋅kn \cdot k 的整数。

家里有 kk 个孩子正等着斯旺女士回家。孩子们最近刚了解了这个橙子,于是决定将它分掉。为此,每个孩子都拿了一张纸,写下自己想要得到的瓣的编号:第 ii 个孩子(1≤i≤k1 \le i \le k)写下了编号 aia_i(1≤ai≤n⋅k1 \le a_i \le n \cdot k)。所有 aia_i 恰好互不相同。

现在孩子们想知道,如何分配这个橙子才能满足以下条件:

  • 每个孩子恰好得到 nn 个橙子瓣;
  • 第 ii 个孩子一定得到编号为 aia_i 的瓣;
  • 任意一个瓣不能同时分给两个孩子。

请帮助孩子们完成橙子的分配,满足上述所有要求。

输入格式

The first line contains two integers n, k (1 ≤ n, k ≤ 30). The second line contains k space-separated integers _a_1, _a_2, ..., a__k (1 ≤ a__i ≤ n·k), where a__i is the number of the orange segment that the i-th child would like to get.

It is guaranteed that all numbers a__i are distinct.

第一行包含两个整数 nn、kk(1≤n,k≤301 \leq n, k \leq 30)。第二行包含 kk 个用空格分隔的整数 a1,a2,…,aka_1, a_2, \dots, a_k(1≤ai≤n⋅k1 \leq a_i \leq n \cdot k),其中 aia_i 表示第 ii 个孩子希望获得的橘子段的编号。

保证所有 aia_i 互不相同。

输出格式

Print exactly n·k distinct integers. The first n integers represent the indexes of the segments the first child will get, the second n integers represent the indexes of the segments the second child will get, and so on. Separate the printed numbers with whitespaces.

You can print a child's segment indexes in any order. It is guaranteed that the answer always exists. If there are multiple correct answers, print any of them.

恰好输出 n⋅kn \cdot k 个互不相同的整数。前 nn 个整数表示第一个孩子将获得的线段的索引,接下来的 nn 个整数表示第二个孩子将获得的线段的索引,依此类推。用空格分隔所输出的数字。

每个孩子所对应的线段索引可以以任意顺序输出。题目保证答案一定存在。若存在多个正确答案,输出任意一个即可。

输入输出样例

  • 输入#1

    2 2
    4 1

    输出#1

    2 4 
    1 3
  • 输入#2

    3 1
    2

    输出#2

    3 2 1

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

首页