Editorial for COCI '15 Contest 3 #2 Esej


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

In this task, we needed to find a large enough number of distinct words. How can we, for instance, generate 50\,000 different words? Fortunately, there are many ways to do this.

One solution is to notice that it is very easy to output a sufficient number of different numbers. For example, we can output them sequentially: 1, 2, 3, \dots, and it is possible to transform these numbers to words by, for example, transforming digits to letters using the key 0a, 1b, 2c, and so on. For instance, the number 451 is transformed to the word efb. If we use this way to transform every integer from 1 to B, all given words are distinct because the initial numbers are also distinct.

If we hadn't thought of this solution, we could have output B words by randomly choosing letters per word (using a function such as rand() in C/C++ or the module random in Python). This approach will be valid because all given words will be distinct with a high probability.


Comments

There are no comments at the moment.