SHOW:
|
|
- or go back to the newest paste.
| 1 | using System; | |
| 2 | ||
| 3 | using System.Collections.Generic; | |
| 4 | ||
| 5 | ||
| 6 | class Program | |
| 7 | {
| |
| 8 | ||
| 9 | static void Main(string[] args) | |
| 10 | {
| |
| 11 | ||
| 12 | ||
| 13 | ||
| 14 | int n = int.Parse(Console.ReadLine()); | |
| 15 | ||
| 16 | //Vkarvame dumite | |
| 17 | ||
| 18 | List<string> words = new List<string>(); | |
| 19 | ||
| 20 | for (int i = 0; i < n; i++) {
| |
| 21 | ||
| 22 | string enteredWord = Console.ReadLine(); | |
| 23 | words.Add(enteredWord); | |
| 24 | ||
| 25 | } | |
| 26 | ||
| 27 | //Razmestvame | |
| 28 | ||
| 29 | ||
| 30 | for (int i = 0; i < words.Count; i++) {
| |
| 31 | ||
| 32 | int pos = words[i].Length % (n + 1); | |
| 33 | ||
| 34 | if (pos < words.Count) {
| |
| 35 | string currentWord = words[i]; | |
| 36 | words.Remove(words[i]); | |
| 37 | words.Insert(pos, currentWord); | |
| 38 | ||
| 39 | ||
| 40 | ||
| 41 | } | |
| 42 | ||
| 43 | ||
| 44 | } | |
| 45 | ||
| 46 | ||
| 47 | //Izchisliavame dyljinata na naj dylgata duma | |
| 48 | ||
| 49 | ||
| 50 | int bestLenght = int.MinValue; | |
| 51 | string strToCheck = " "; | |
| 52 | for (int i = 0; i < words.Count; i++) | |
| 53 | {
| |
| 54 | strToCheck = words[i]; | |
| 55 | ||
| 56 | if (strToCheck.Length > bestLenght) | |
| 57 | {
| |
| 58 | ||
| 59 | bestLenght = strToCheck.Length; | |
| 60 | ||
| 61 | ||
| 62 | } | |
| 63 | ||
| 64 | ||
| 65 | ||
| 66 | } | |
| 67 | ||
| 68 | ||
| 69 | - | //Pravim vsichki taka |
| 69 | + | //Pravim vsichki dumi s takava dyljina kato na praznoto mqsto slagame # |
| 70 | ||
| 71 | for (int i = 0; i < words.Count; i++) | |
| 72 | {
| |
| 73 | ||
| 74 | string currentWord = words[i]; | |
| 75 | ||
| 76 | for (int j = 0; j <= bestLenght; j++) | |
| 77 | {
| |
| 78 | ||
| 79 | if (currentWord.Length < j) | |
| 80 | {
| |
| 81 | ||
| 82 | currentWord += "#"; | |
| 83 | ||
| 84 | } | |
| 85 | ||
| 86 | ||
| 87 | ||
| 88 | ||
| 89 | } | |
| 90 | ||
| 91 | words[i] = currentWord; | |
| 92 | ||
| 93 | ||
| 94 | ||
| 95 | } | |
| 96 | ||
| 97 | ||
| 98 | ||
| 99 | //Pochvame da syzdavame magicheskata duma | |
| 100 | ||
| 101 | int f = 0; | |
| 102 | string wordToCheck = " "; | |
| 103 | string magicWord = ""; | |
| 104 | ||
| 105 | for (int i = 0; i < bestLenght; i++) {
| |
| 106 | ||
| 107 | for (int j = 0; j < words.Count; j++) {
| |
| 108 | wordToCheck = words[j]; | |
| 109 | if (wordToCheck[f] != '#') {
| |
| 110 | magicWord += wordToCheck[f]; | |
| 111 | ||
| 112 | } | |
| 113 | ||
| 114 | ||
| 115 | ||
| 116 | } | |
| 117 | ||
| 118 | f++; | |
| 119 | ||
| 120 | ||
| 121 | ||
| 122 | } | |
| 123 | ||
| 124 | ||
| 125 | ||
| 126 | ||
| 127 | Console.WriteLine(magicWord); | |
| 128 | ||
| 129 | ||
| 130 | ||
| 131 | } | |
| 132 | } |