CF771B.Bear and Different Names

普及/提高-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 _s_1, _s_2, ..., s__n - k + 1, each either "YES" or "NO".

  • The string _s_1 describes a group of soldiers 1 through k ("YES" if the group is effective, and "NO" otherwise).
  • The string _s_2 describes a group of soldiers 2 through k + 1.
  • And so on, till the string s__n - 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.

在军队中,组建一支在战场上高效的士兵小队并非易事。通信至关重要,因此任意两名士兵不得拥有相同的名字(试想,若命令“Bob 是侦察兵”,而恰好有两名 Bob,会发生什么?)。

当且仅当小队中所有士兵的名字互不相同时,该小队才被视为高效。例如,小队(John, Bob, Limak)是高效的;而小队(Gary, Bob, Gary)和(Alice, Alice)则不是。

你是一名潜伏于敌方营地的间谍。你观察到有 $ n $ 名士兵排成一列,编号为 $ 1 $ 至 $ n $。将军希望从中选出 $ k $ 名连续的士兵组成一个小队。对于每一个长度为 $ k $ 的连续子序列,将军均记录下该小队是否高效。

你成功窃取了将军的笔记,其中包含 $ n - k + 1 $ 个字符串 $ s_1, s_2, \dots, s_{n - k + 1} $,每个字符串均为 "YES" 或 "NO":

  • 字符串 $ s_1 $ 描述士兵 $ 1 $ 至 $ k $ 组成的小队(若该小队高效则为 "YES",否则为 "NO");
  • 字符串 $ s_2 $ 描述士兵 $ 2 $ 至 $ k + 1 $ 组成的小队;
  • 依此类推,直至字符串 $ s_{n - k + 1} $,它描述士兵 $ n - k + 1 $ 至 $ n $ 组成的小队。

你的任务是为这 $ n $ 名士兵构造一组可能的名字,使其与所窃取的笔记完全吻合。每个名字必须是由 1 到 10 个英文字母组成的字符串,首字母大写,其余字母小写。名字无需是真实存在的名字——例如输出 "Xyzzzdj" 或 "T" 均可接受。

请找出并输出任意一组满足条件的解。可以证明:至少存在一个解。

输入格式

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 _s_1, _s_2, ..., s__n - k + 1. The string s__i is "YES" if the group of soldiers i through i + k - 1 is effective, and "NO" otherwise.

输入的第一行包含两个整数 nn 和 kk(2 ≤ k ≤ n ≤ 502 \leq k \leq n \leq 50),分别表示士兵的数量和小组的大小。

第二行包含 n − k + 1n - k + 1 个字符串 s1, s2, ..., sn − k + 1s_1,\,s_2,\,...,\,s_{n - k + 1}。若从第 ii 位到第 i + k − 1i + k - 1 位的士兵组成的小组是有效的,则字符串 sis_i 为 "YES";否则为 "NO"。

输出格式

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.

找出任意一组满足所有给定条件的解。在一行中输出 n 个用空格分隔的字符串,表示士兵可能的名字(按顺序)。每个名字的首字母应为大写,其余字母应为小写。每个名字仅包含英文字母,且长度为 1 到 10。

若存在多个合法解,输出其中任意一个即可。

输入输出样例

  • 输入#1

    8 3
    NO NO YES YES YES NO

    输出#1

    Adam Bob Bob Cpqepqwer Limak Adam Bob Adam
  • 输入#2

    9 8
    YES NO

    输出#2

    R Q Ccccccccc Ccocc Ccc So Strong Samples Ccc
  • 输入#3

    3 2
    NO NO

    输出#3

    Na Na Na

说明/提示

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 _s_1 is "NO".
  • Soldiers 2 through 4 (Bob, Bob, Cpqepqwer) wouldn't be effective either, and the string _s_2 is "NO".
  • Soldiers 3 through 5 (Bob, Cpqepqwer, Limak) would be effective, and the string _s_3 is "YES".
  • ...,
  • Soldiers 6 through 8 (Adam, Bob, Adam) wouldn't be effective, and the string _s_6 is "NO".

在第一个样例中,共有 8 名士兵。对于每连续的 3 名士兵,我们知道他们是否能组成一个有效的小组。我们来分析所提供的样例输出:

  • 前三名士兵(即 Adam、Bob、Bob)无法组成一个有效的小组,因为其中有两个 Bob。事实上,字符串 s1s_1 为 "NO"。
  • 第 2 至第 4 名士兵(Bob、Bob、Cpqepqwer)同样无法组成有效小组,字符串 s2s_2 为 "NO"。
  • 第 3 至第 5 名士兵(Bob、Cpqepqwer、Limak)可以组成有效小组,字符串 s3s_3 为 "YES"。
  • …,
  • 第 6 至第 8 名士兵(Adam、Bob、Adam)无法组成有效小组,字符串 s6s_6 为 "NO"。

输入解题思路,AI测评打分。不知道怎么写?

首页