CF1552E.Colors and Intervals
提高+/省选-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The numbers 1,2,…,n⋅k are colored with n colors. These colors are indexed by 1,2,…,n. For each 1≤i≤n, there are exactly k numbers colored with color i.
Let [a,b] denote the interval of integers between a and b inclusive, that is, the set a,a+1,…,b. You must choose n intervals [a1,b1],[a2,b2],…,[an,bn] such that:
- for each 1≤i≤n, it holds 1≤ai<bi≤n⋅k;
- for each 1≤i≤n, the numbers ai and bi are colored with color i;
- each number 1≤x≤n⋅k belongs to at most ⌈k−1n⌉ intervals.
One can show that such a family of intervals always exists under the given constraints.
数字 1,2,…,n⋅k 被用 n 种颜色染色。这些颜色编号为 1,2,…,n。对每个 1≤i≤n,恰好有 k 个数被染成颜色 i。
记 [a,b] 为从 a 到 b(含端点)的所有整数构成的区间,即集合 {a,a+1,…,b}。你需要选出 n 个区间 [a1,b1],[a2,b2],…,[an,bn],满足:
- 对每个 1≤i≤n,均有 1≤ai<bi≤n⋅k;
- 对每个 1≤i≤n,数 ai 和 bi 均被染成颜色 i;
- 每个数 1≤x≤n⋅k 至多属于 ⌈k−1n⌉ 个区间。
可以证明:在给定约束条件下,这样的区间族总存在。
输入格式
The first line contains two integers n and k (1≤n≤100, 2≤k≤100) — the number of colors and the number of occurrences of each color.
The second line contains n⋅k integers c1,c2,…,cnk (1≤cj≤n), where cj is the color of number j. It is guaranteed that, for each 1≤i≤n, it holds cj=i for exactly k distinct indices j.
第一行包含两个整数 n 和 k(1≤n≤100,2≤k≤100)—— 分别表示颜色种类数和每种颜色出现的次数。
第二行包含 n⋅k 个整数 c1,c2,…,cnk(1≤cj≤n),其中 cj 表示编号为 j 的数字的颜色。保证对于每个 1≤i≤n,恰好存在 k 个不同的下标 j 满足 cj=i。
输出格式
Output n lines. The i-th line should contain the two integers ai and bi.
If there are multiple valid choices of the intervals, output any.
输出 n 行。第 i 行应包含两个整数 ai 和 bi。
如果存在多个满足条件的区间选择方案,输出任意一个即可。
输入输出样例
输入#1
4 3 2 4 3 1 1 4 2 3 2 1 3 4
输出#1
4 5 1 7 8 11 6 12
输入#2
1 2 1 1
输出#2
1 2
输入#3
3 3 3 1 2 3 2 1 2 1 3
输出#3
6 8 3 7 1 4
输入#4
2 3 2 1 1 1 2 2
输出#4
2 3 5 6
说明/提示
In the first sample, each number can be contained in at most ⌈3−14⌉=2 intervals. The output is described by the following picture:

In the second sample, the only interval to be chosen is forced to be [1,2], and each number is indeed contained in at most ⌈2−11⌉=1 interval.
In the third sample, each number can be contained in at most ⌈3−13⌉=2 intervals. The output is described by the following picture:

在第一个样例中,每个数最多可被 ⌈3−14⌉=2 个区间包含。输出由下图描述:

在第二个样例中,唯一可选的区间被迫为 [1,2],且每个数确实最多被 ⌈2−11⌉=1 个区间包含。
在第三个样例中,每个数最多可被 ⌈3−13⌉=2 个区间包含。输出由下图描述:

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