Editorial for COCI '22 Contest 4 #1 7Krokods


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 the first subtask, Paula has no crocodile cards, so we only need to compute the score as described in the task statement.

In the second subtask, Paula has one crocodile card. We can try replacing the card with each of the letters d, k, o, and r, calculate the score for each, and then output the maximum among the scores.

In the third subtask, Paula can have up to 10 crocodile cards. We want to try all possible combinations of replacing crocodile cards, i.e. we want to find all combinations of numbers d, k, o, r (0 \le d, k, o, r \le m) such that d+k+o+r \le m, where m is the number of crocodile cards. Since m is only up to 10, we can try all combinations with 4 nested loops, each going from 0 to m, and each representing the number of crocodile cards that will be replaced with a certain letter. For each combination, we will check if their sum isn't bigger than m, and then calculate the score. As in the second subtask, we will output the maximum among the scores.


Comments

There are no comments at the moment.