CF1552E.Colors and Intervals
普及/提高-
通过率:0%
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.
输入格式
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 .
输出格式
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.
输入输出样例
输入#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: