771B.md (3512B)
1 Source: https://codeforces.com/problemset/problem/771/B 2 3 B. Bear and Different Names 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 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?). 22 23 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. 24 25 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. 26 27 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". 28 29 * The string *s*1 describes a group of soldiers 1 through *k* ("YES" if the group is effective, and "NO" otherwise). 30 * The string *s*2 describes a group of soldiers 2 through *k* + 1. 31 * And so on, till the string *s**n* - *k* + 1 that describes a group of soldiers *n* - *k* + 1 through *n*. 32 33 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. 34 35 Find and print any solution. It can be proved that there always exists at least one solution. 36 37 Input 38 39 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. 40 41 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. 42 43 Output 44 45 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. 46 47 If there are multiple valid solutions, print any of them. 48 49 Examples 50 51 Input 52 53 ``` 54 8 3 55 NO NO YES YES YES NO 56 ``` 57 58 Output 59 60 ``` 61 Adam Bob Bob Cpqepqwer Limak Adam Bob Adam 62 ``` 63 64 Input 65 66 ``` 67 9 8 68 YES NO 69 ``` 70 71 Output 72 73 ``` 74 R Q Ccccccccc Ccocc Ccc So Strong Samples Ccc 75 ``` 76 77 Input 78 79 ``` 80 3 2 81 NO NO 82 ``` 83 84 Output 85 86 ``` 87 Na Na Na 88 ``` 89 90 Note 91 92 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: 93 94 * 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". 95 * Soldiers 2 through 4 (Bob, Bob, Cpqepqwer) wouldn't be effective either, and the string *s*2 is "NO". 96 * Soldiers 3 through 5 (Bob, Cpqepqwer, Limak) would be effective, and the string *s*3 is "YES". 97 * ..., 98 * Soldiers 6 through 8 (Adam, Bob, Adam) wouldn't be effective, and the string *s*6 is "NO".