Problem

 

C.    Mahershalalhashbaz, Nebuchadnezzar, and Billy Bob Benjamin Go to the Regionals
Time Limit: 0.5 Seconds    Memory Limit: 65536K



The Association for Computing Machinery (ACM) is considering new rules for its regional programming contests, in part to solve some software problems. For instance, the program that prints out the badges for each team was designed so that the same font size is used to print all badges for that team. However, this means that if one member of the team has a very long name, then a very small font will be used to print all of the team's badges, and this wouldn't look very nice for someone with an extremely short name like "AL".

The initial solution proposed by the ACM was to put a limit on the length of contestants' names. Someone pointed out that this would discriminate against teams from certain regions where bigger names are more common (for instance, children in the home towns of well-known actors are more likely to be named after that actor – imagine how many children in Oakland, California have been named after the actor Mahershalalhashbaz Ali since he became one of the stars of the television series The 4400).

As a compromise, the ACM decided to change the rule to require that "no team member's name can have length more than two away from the average length of all the team member's names." Using this rule, a team consisting of "MAHERSHALALHASHBAZ", "AL", and "BILL" would be disqualified (average name length is 8, so AL and BILL are not within 2). However, "MAHERSHALALHASHBAZ", "NEBUCHADNEZZAR", and "BILLYBOBBENJAMIN" would be okay (average name length is 16, and all team member names have length within 2 of this number).

Given the names of n students, determine whether or not they can be placed into teams of k members each so that each team meets the requirements of the new ACM rule.

 

Input

Input will consist of multiple test cases. Each test case begins with a line consisting of two positive integers n and k, where n ≤ 1000, k ≤ 8, and n is divisible by k. Following this are n lines, each containing a single name consisting only of upper case letters with no embedded, leading, or trailing blanks. These are the names of the n students who need to be organized into teams of size k each. No name will exceed 80 characters. The last test case is followed by a line containing two zeros.

 

Output

For each test case, output the case number (starting at 1) followed by either the word "yes" (meaning that it is possible to organize the students into teams of size k so that no student on that team has a name whose length is greater than distance 2 from the average name lengths of the members on that team), or "no" if it is not possible. Use the format shown in the sample output. Insert a blank line between cases.

 

Sample Input

3 3
MAHERSHALALHASHBAZ
AL
BILL
6 3
MAHERSHALALHASHBAZ
AL
NEBUCHADNEZZAR
BILL
BILLYBOBBENJAMIN
JILL
0 0

 

Sample Output

Case 1: no

Case 2: yes
 
学校练习赛的一题, 很简单, 就是把名字按照长度排下序, 然后计算每K个名字和这K个名字长度的均值差<2...
就是这么简单道题, WA疯了, 8次, 笨死了...(粗心)...
 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值