C. Bear and Different Names
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

In the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should share a name (what would happen if they got an order that Bob is a scouter, if there are two Bobs?).

A group of soldiers is effective if and only if their names are different. For example, a group (John, Bob, Limak) would be effective, while groups (Gary, Bob, Gary) and (Alice, Alice) wouldn't.

You are a spy in the enemy's camp. You noticed n soldiers standing in a row, numbered 1 through n. The general wants to choose a group of k consecutive soldiers. For every k consecutive soldiers, the general wrote down whether they would be an effective group or not.

You managed to steal the general's notes, with n - k + 1 strings s1, s2, ..., sn - k + 1, each either "YES" or "NO".

  • The string s1 describes a group of soldiers 1 through k ("YES" if the group is effective, and "NO" otherwise).
  • The string s2 describes a group of soldiers 2 through k + 1.
  • And so on, till the string sn - k + 1 that describes a group of soldiers n - k + 1 through n.

Your task is to find possible names of n soldiers. Names should match the stolen notes. Each name should be a string that consists of between 1 and 10 English letters, inclusive. The first letter should be uppercase, and all other letters should be lowercase. Names don't have to be existing names — it's allowed to print "Xyzzzdj" or "T" for example.

Find and print any solution. It can be proved that there always exists at least one solution.

Input

The first line of the input contains two integers n and k (2 ≤ k ≤ n ≤ 50) — the number of soldiers and the size of a group respectively.

The second line contains n - k + 1 strings s1, s2, ..., sn - k + 1. The string si is "YES" if the group of soldiers i through i + k - 1 is effective, and "NO" otherwise.

Output

Find any solution satisfying all given conditions. In one line print n space-separated strings, denoting possible names of soldiers in the order. The first letter of each name should be uppercase, while the other letters should be lowercase. Each name should contain English letters only and has length from 1 to 10.

If there are multiple valid solutions, print any of them.

Examples
input
8 3
NO NO YES YES YES NO
output
Adam Bob Bob Cpqepqwer Limak Adam Bob Adam
input
9 8
YES NO
output
R Q Ccccccccc Ccocc Ccc So Strong Samples Ccc
input
3 2
NO NO
output
Na Na Na
Note

In the first sample, there are 8 soldiers. For every 3 consecutive ones we know whether they would be an effective group. Let's analyze the provided sample output:

  • First three soldiers (i.e. Adam, Bob, Bob) wouldn't be an effective group because there are two Bobs. Indeed, the string s1 is "NO".
  • Soldiers 2 through 4 (Bob, Bob, Cpqepqwer) wouldn't be effective either, and the string s2 is "NO".
  • Soldiers 3 through 5 (Bob, Cpqepqwer, Limak) would be effective, and the string s3 is "YES".
  • ...,
  • Soldiers 6 through 8 (Adam, Bob, Adam) wouldn't be effective, and the string s6 is "NO".

————————————————————————————————

题目的意思是如果连续的k个人有重复,那么就会NO,让你构造一个序列符合给出的信息,序列首字母大写,剩下的小写

思路:先初始化一个都不一样的序列,然后处理,每次遇到NO就让该位变成他前面的第k+1位

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <climits> using namespace std; #define LL long long
const int INF = 0x3f3f3f3f; string a[105]; int main()
{
int m,n;
char s[100];
a[1]="aa";
for(int i=2; i<100; i++)
{
a[i]=a[i-1];
a[i][1]++;
if(i%26==1&&i>1)
a[i]=a[i-26],a[i][0]++;
}
scanf("%d%d",&n,&m);
for(int i=m; i<=n; i++)
{
scanf("%s",s);
if(strcmp(s,"YES"))
a[i]=a[i-m+1];
}
int q=0;
for(int i=1; i<=n; i++)
{
if(q++)
printf(" ");
cout<<"A"<<a[i];
}
printf("\n");
return 0;
}

  

Codeforces791 C. Bear and Different Names的更多相关文章

  1. Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) C. Bear and Different Names 贪心

    C. Bear and Different Names 题目连接: http://codeforces.com/contest/791/problem/C Description In the arm ...

  2. Codeforces 791C. Bear and Different Names 模拟构造

    C. Bear and Different Names time limit per test:1 second memory limit per test:256 megabytes input:s ...

  3. Codeforces791 B. Bear and Friendship Condition

    B. Bear and Friendship Condition time limit per test 1 second memory limit per test 256 megabytes in ...

  4. 【构造】Codeforces Round #405 (rated, Div. 1, based on VK Cup 2017 Round 1) A. Bear and Different Names

    如果某个位置i是Y,直接直到i+m-1为止填上新的数字. 如果是N,直接把a[i+m-1]填和a[i]相同即可,这样不影响其他段的答案. 当然如果前面没有过Y的话,都填上0就行了. #include& ...

  5. 【codeforces 791C】Bear and Different Names

    [题目链接]:http://codeforces.com/contest/791/problem/C [题意] 给你n-k+1个限制 要求 a[i]..a[i]+k-1里面有相同的元素,或全都不同; ...

  6. VK Cup 2017 - Round 1

    和FallDream组队瞎打一通--B两个人写的都挂了233,最后只剩下FallDream写的A和我写的C,最后我yy了个E靠谱做法结果打挂了,结束之后改了改就A了,难受. AC:AC Rank:18 ...

  7. Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1)A B C 水 并查集 思路

    A. Bear and Big Brother time limit per test 1 second memory limit per test 256 megabytes input stand ...

  8. 【Codeforces Round #405 ( Div 2)】题解

    Bear and Big Brother 签到题,直接模拟就可以了. Bear and Friendship Condition 满足只能是每个朋友圈中每个人和其他人都是朋友,这样的边数的确定的. 然 ...

  9. Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) 菜鸡只会ABC!

    Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) 全场题解 菜鸡只会A+B+C,呈上题解: A. Bear and ...

随机推荐

  1. Eclipse 安装中文简体语言包

    Installing the language packs Open the install wizard with 'Help' > 'Install new software...' Add ...

  2. 转:解决AndroidStudio连不上Android设备真机的问题

    Android手机开发Android应用的时候,需要连接真机,进行应用软件的真机调试,但是由于诸多原因,可能导致无法与实现连接: 在我们连接了Android设备出现上面这种情况的时候,可以打开设备管理 ...

  3. 数据库设计,表与表的关系,一对多。One-To-Many(2)

    一对多:主键数据表中只能包含一个记录,而在其关系记录表中这条记录可以与一个或多个记录相关,也可以没有记录与之相关. 关联映射:一对多/多对一存在最普遍的映射关系,简单来讲就如球员与球队的关系:一对多: ...

  4. week07 13.1 NewsPipeline之 一 NewsMonitor

    我们要重构一下代码 因为我们之前写了utils 我们的NewsPipeline部分也要用到 所以我们把他们单独独立得拿出来 删掉原来的 将requirements.txt也拿出去 现在我们搬家完成 我 ...

  5. Beta冲刺——第一天

    beta冲刺:第一天 各个成员今日完成的任务 成员 冯晓.马思远 彭辉.王爽 吴琼.郝延婷 今日完成任务 ·参会人员注册代码规范与功能测试 ·网站的前端代码调整 ·代码规范 ·系统功能测试 ·博客撰写 ...

  6. 使用rpm-build制作nginx的rpm包

    2014-11-27 11:05:49   一.RPM包的分类 RPM有五种基本的操作功能:安装.卸载.升级.查询和验证. linux软件包分为两大类: (1)二进制类包,包括rpm安装包(一般分为i ...

  7. C#//字节数组转16进制字符串

    //字节数组转16进制字符串 private static string byteToHexStr(byte[] bytes,int length) { string returnStr = &quo ...

  8. python 路径处理

    1.分解路径名 比如要把xxx/yyy/zzz.py 分解成文件名和目录 两种方法: 一.os.path.split(file) 二.os.path.basename()  ;   os.path.d ...

  9. python生成器(generator)、迭代器(iterator)、可迭代对象(iterable)区别

    三者联系 迭代器(iterator)是一个更抽象的概念,任何对象,如果它的类有next方法(next python3)和__iter__方法返回自己本身,即为迭代器 通常生成器是通过调用一个或多个yi ...

  10. oracle 新增并返回新增的主键

    oracle 的insert into 语句需要返回新增的主键的时候,可以使用一下insert 语法: insert into ims.t_bank_inquire_results (t_date,l ...