CF1118E.Yet Another Ball Problem
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The king of Berland organizes a ball! n pair are invited to the ball, they are numbered from 1 to n . Each pair consists of one man and one woman. Each dancer (either man or woman) has a monochrome costume. The color of each costume is represented by an integer from 1 to k , inclusive.
Let bi be the color of the man's costume and gi be the color of the woman's costume in the i -th pair. You have to choose a color for each dancer's costume (i.e. values b1,b2,…,bn and g1,g2,…gn ) in such a way that:
- for every i : bi and gi are integers between 1 and k , inclusive;
- there are no two completely identical pairs, i.e. no two indices i,j ( i=j ) such that bi=bj and gi=gj at the same time;
- there is no pair such that the color of the man's costume is the same as the color of the woman's costume in this pair, i.e. bi=gi for every i ;
- for each two consecutive (adjacent) pairs both man's costume colors and woman's costume colors differ, i.e. for every i from 1 to n−1 the conditions bi=bi+1 and gi=gi+1 hold.
Let's take a look at the examples of bad and good color choosing (for n=4 and k=3 , man is the first in a pair and woman is the second):
Bad color choosing:
- (1,2) , (2,3) , (3,2) , (1,2) — contradiction with the second rule (there are equal pairs);
- (2,3) , (1,1) , (3,2) , (1,3) — contradiction with the third rule (there is a pair with costumes of the same color);
- (1,2) , (2,3) , (1,3) , (2,1) — contradiction with the fourth rule (there are two consecutive pairs such that colors of costumes of men/women are the same).
Good color choosing:
- (1,2) , (2,1) , (1,3) , (3,1) ;
- (1,2) , (3,1) , (2,3) , (3,2) ;
- (3,1) , (1,2) , (2,3) , (3,2) .
You have to find any suitable color choosing or say that no suitable choosing exists.
输入格式
The only line of the input contains two integers n and k ( 2≤n,k≤2⋅105 ) — the number of pairs and the number of colors.
输出格式
If it is impossible to find any suitable colors choosing, print "NO".
Otherwise print "YES" and then the colors of the costumes of pairs in the next n lines. The i -th line should contain two integers bi and gi — colors of costumes of man and woman in the i -th pair, respectively.
You can print each letter in any case (upper or lower). For example, "YeS", "no" and "yES" are all acceptable.
输入输出样例
输入#1
4 3
输出#1
YES 3 1 1 3 3 2 2 3
输入#2
10 4
输出#2
YES 2 1 1 3 4 2 3 4 4 3 3 2 2 4 4 1 1 4 3 1
输入#3
13 4
输出#3
NO