Bear and Different Names
来源:互联网 发布:关于网络暴力的调查 编辑:程序博客网 时间:2024/06/06 03:53
D - Bear and Different Names
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.
Example
Input
8 3
NO NO YES YES YES NO
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.
Example
Input
8 3
NO NO YES YES YES NO
Output
Adam Bob Bob Cpqepqwer Limak Adam Bob Adam
Input
YES NO
Output
R Q Ccccccccc Ccocc Ccc So Strong Samples Ccc
Input
NO NO
Output
Na Na Na
题解:打表,如果哪组名字不满足,那就让它的最后一个人的名字等于该组第一个人的名字。
#include<stdio.h>#include<string.h>int main(){char a[50][5]={{"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"},{"Bb"},{"Cc"},{"Dd"},{"Ee"},{"Ff"},{"Gg"},{"Hh"},{"Ii"},{"Jj"},{"Kk"},{"Ll"},{"Mm"},{"Nn"},{"Oo"},{"Pp"},{"Qq"},{"Rr"},{"Ss"},{"Tt"},{"Uu"},{"Vv"},{"Ww"},{"Xx"},{"Yy"}};int n,k;//printf("%s",a[8]);scanf("%d%d",&n,&k);int i;char b[50][5];for(i=0;i<n-k+1;i++){scanf("%s",b[i]);} if(strcmp(b[0],"NO")==0){strcpy(a[k-1],a[0]);//printf("%s",a[2]);}for(i=1;i<n-k+1;i++) {if(strcmp(b[i],"NO")==0){strcpy(a[i+k-1],a[i]);}}for(i=0;i<n;i++){printf("%s ",a[i]);}return 0; }
阅读全文
0 0
- Bear and Different Names
- codeforces Bear and Different Names
- C. Bear and Different Names
- codefroces 791C Bear and Different Names
- CodeForces 791C Bear and Different Names
- CodeForces 791C Bear and Different Names
- (codeforces)B. Bear and Different Names
- Codeforces791 C. Bear and Different Names
- Codeforces 791C Bear and Different Names 简单构造
- Codeforces Round #405 C. Bear and Different Names (思维)
- Codeforces Round #405 C.Bear and Different Names【思维】
- Codeforces 771B Bear and Different Names[构造]
- Codeforces Round #405 C. Bear and Different Names
- Codeforces 791 C. Bear and Different Names【贪心】
- codeforce771B Bear and Different Names 贪心or思维
- (贪心)Codeforces Round #405 C. Bear and Different Names
- web service错误Use @XmlType.name and @XmlType.namespace to assign different names to them.
- Bear and Raspberry
- Android常用开源框架的源码解读套路--教你怎么读开源框架源码
- 闲暇时光-越是忙碌的时候,越想找一个地方,自在独处
- 2017/7/27 第四天
- 2017 HDU 多校联合赛 Regular polygon
- 对表空间 'USERS' 无权限
- Bear and Different Names
- spring-task的配置及使用
- Jmeter录制脚本相应数据产生乱码解决方案
- 面向对象地分析Linux内核设备驱动(3)——用面向对象思想分析vfb Framebuffer设备驱动
- Unity_NGUI介绍_038
- SpringBoot (六) :如何优雅的使用 mybatis
- 黄海高程和绝对高程之间的转换
- [简单DP]Max Sum Plus Plus HDU 102
- python002 Python3 基础语法