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".

题目链接:http://codeforces.com/contest/791/problem/C

题意:有n个人,按照每k个人进行分组:1~k,2~k+1,3~k+2...,n-k+1~n。如果本组内有名字相同的人,这一组表示为"NO";否者表示为"YES"。现在要求你构造n个人的名字,名字由一个长度不超过10的字母字符串组成,并且首字母大写。

思路:初始化每个人的名字为ans[i]=i。那么每个人的名字均不相同,但是有一些分组的人的名字是相同的,即为"NO"的情况。所以要更改这一组的一些人的名字,但是不能影响上一组和下一组。本组的前k-1个人与上一组的人重合,本组的后k-1个人与下一组重合。所以更改为本组的第一个人的名字和本组的第k个人的名字相同不会对上一组和下一组造成影响。

代码:

 #include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
const int MAXN=2e5+,INF=0x3f3f3f3f,MOD=1e9+;
char s[][];
string sign[]= {"Aa","Ab","Ac","Ad","Ae","Af","Ag","Ah","Ai","Aj",
"Ak","Al","Am","An","Ao","Ap","Aq","Ar","As","At",
"Au","Av","Aw","Ax","Ay","Az","Ba","Bb","Bc","Bd",
"Be","Bf","Bg","Bh","Bi","Bj","Bk","Bl","Bm","Bn",
"Bo","Bp","Bq","Br","Bs","Bt","Bu","Bv","Bw","Bx",
"By","Bz","Ca","Cb","Cc","Cd","Ce","Cf","Cg","Ch"
};
int ans[];
int main()
{
int n,k;
scanf("%d%d",&n,&k);
int x=n-k;
for(int i=; i<=x; i++) scanf("%s",s[i]);
for(int i=; i<n; i++) ans[i]=i;
for(int i=; i<=x; i++)
{
if(s[i][]=='Y') continue;
ans[i+k-]=ans[i];
}
for(int i=; i<n; i++)
cout<<sign[ans[i]]<<" ";
cout<<endl;
return ;
}

Codeforces 791C. Bear and Different Names 模拟构造的更多相关文章

  1. Codeforces 798C. Mike and gcd problem 模拟构造 数组gcd大于1

    C. Mike and gcd problem time limit per test: 2 seconds memory limit per test: 256 megabytes input: s ...

  2. CodeForces 658C Bear and Forgotten Tree 3 (构造)

    题意:构造出一个 n 个结点,直径为 m,高度为 h 的树. 析:先构造高度,然后再构造直径,都全了,多余的边放到叶子上,注意直径为1的情况. 代码如下: #pragma comment(linker ...

  3. 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 ...

  4. Codeforces791 C. Bear and Different Names

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

  5. Codeforces 385C Bear and Prime Numbers

    题目链接:Codeforces 385C Bear and Prime Numbers 这题告诉我仅仅有询问没有更新通常是不用线段树的.或者说还有比线段树更简单的方法. 用一个sum数组记录前n项和, ...

  6. Codeforces 385B Bear and Strings

    题目链接:Codeforces 385B Bear and Strings 记录下每一个bear的起始位置和终止位置,然后扫一遍记录下来的结构体数组,过程中用一个变量记录上一个扫过的位置,用来去重. ...

  7. 学习xss模拟构造攻击(第一篇)

    本文作者:i春秋签约作家——rosectow 0×00前言 XSS又名叫CSS全程(cross site scriptting),中文名跨站脚本攻击,目前网站的常见漏洞之一,它的危害没有像上传漏洞,s ...

  8. Codeforces 680D Bear and Tower of Cubes 贪心 DFS

    链接 Codeforces 680D Bear and Tower of Cubes 题意 求一个不超过 \(m\) 的最大体积 \(X\), 每次选一个最大的 \(x\) 使得 \(x^3\) 不超 ...

  9. Codeforces 385C Bear and Prime Numbers(素数预处理)

    Codeforces 385C Bear and Prime Numbers 其实不是多值得记录的一道题,通过快速打素数表,再做前缀和的预处理,使查询的复杂度变为O(1). 但是,我在统计数组中元素出 ...

随机推荐

  1. mysql ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

    为了加强安全性,MySQL5.7为root用户随机生成了一个密码,在error log中,关于error log的位置,如果安装的是RPM包,则默认是/var/log/mysqld.log. 一般可通 ...

  2. hashcode() equals()

     介绍一. hashCode()方法和equal()方法的作用其实一样,在Java里都是用来对比两个对象是否相等一致,那么equal()既然已经能实现对比的功能了,为什么还要hashCode()呢? ...

  3. 1.3.1、CDH 搭建Hadoop在安装之前(端口---Cloudera Manager和Cloudera Navigator使用的端口)

    下图概述了Cloudera Manager,Cloudera Navigator和Cloudera Management Service角色使用的一些端口: Cloudera Manager和Clou ...

  4. async.waterfall

    [async.waterfall] if any of the tasks pass an error to their own callback, the next function is not ...

  5. yum更换阿里源

    备份mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup 下载新的CentOS-Base.repo ...

  6. JAVA高精度模板

    刚开始还坚持用C++写高精来着,后来发现JAVA写高精方便太多了,所以也来学习一下JAVA高精度的模板. 参考:https://www.cnblogs.com/imzscilovecode/p/883 ...

  7. ceph 维护之 osd节点添加

    一.目标 添加一台新osd 节点,主机名ceph6 到 ceph 集群.public IP:10.6.32.25      cluster_network :10.6.33.25 二.基础环境配置 1 ...

  8. 微信小程序——过滤器的模拟

    >> 编写wxs文件——filter.wxs //1. 价格格式化 function getPriceFormat(value) { return parseFloat(isNaN(val ...

  9. 【python】初识python

    [命名规范] 模块名:小写字母,单词之间用_分割:例如:ad_stats.py 包名:和模块名一样 类名:单词首字母大写:例如:ConfigUtil 全局变量名:大写字母,单词之间用_分割:例如:NU ...

  10. PTA 7-33 地下迷宫探索(深搜输出路径)

    地道战是在抗日战争时期,在华北平原上抗日军民利用地道打击日本侵略者的作战方式.地道网是房连房.街连街.村连村的地下工事,如下图所示. 我们在回顾前辈们艰苦卓绝的战争生活的同时,真心钦佩他们的聪明才智. ...