CODEFORCE #405 div1 a

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

题意:
有n个基佬,每k个连续的基佬,YES代表他们没有相同的名字,NO表示至少有2个人有相同的名字,让你构造这n个基佬的名字

思路:
至少嘛,那我们就搞一头一尾咯,先构造一个他们都有不同的名字,然后再根据YES OR NO 来构造,因为每个区间是互不影响的,所以NO的时候尾部等于头部就行,YES就不变,而为什么头部等于尾部不行,因为尾部在接下来的遍历中有可能会改变,而让尾部等于头部就不影响前面的序列了.

code:

#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
using namespace std;
typedef long long LL;
int n, m,mark;
string judge[50];
string ans[60];
int main()
{
    cin >> n >> m;
    for (int i = 1; i <= (n - m + 1); i++)
    {
        cin >> judge[i];
    }
    mark = m + 1;
    ans[1] = "A";
    for (int i = 2; i <= 10; i++)
    {

        ans[i] = ans[i - 1] + 'a';
    }
    ans[11]="B";
    for (int i = 12; i <= 20; i++)
    {
        ans[i] = ans[i - 1] + 'a';
    }
    ans[21] = "C";
    for (int i = 22; i <= 30; i++)
    {
        ans[i] = ans[i - 1] + 'a';
    }
    ans[31] = "D";
    for (int i = 32; i <= 40; i++)
    {
        ans[i] = ans[i - 1] + 'a';
    }
    ans[41] = "F";
    for (int i = 42; i <= 50; i++)
    {
        ans[i] = ans[i - 1] + 'a';
    }
    for (int i = 1; i <= (n - m + 1); i++)
    {
        if (judge[i] == "YES")
        {
            continue;
        }
        else
        {
            ans[i+m-1] = ans[i];
        }
    }
    for (int i = 1; i <= n; i++)
        cout << ans[i] << ' ';
    cout << endl;
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值