Diego1149's blog

By Diego1149, history, 3 years ago, In English

Congratulations to the contestants that made it to world finals!!

I think this was one of the most competed regionals I've ever seen!

I feel like the quality of the problems has been going up in the past 10 years, so congratulations to all of the problem setters as well!

Scoreboard: https://scorelatam.naquadah.com.br/latam-2020/?fbclid=IwAR2L3sSAX_iD4oB01HVewrlnqZpbm4hVw6aEg-u4FOkZ0CutkFbtgLKPuMQ#

Here I give a subjective difficulty to the problems:

  • Easy: DLN
  • Medium-Easy: CEK
  • Medium-Hard: BFHJ
  • Hard: AGI
  • Very Hard: M

For Mexico solving all of Easy, Medium-Easy and 2 of the Medium-Hard would guarantee pass to world finals.

For other regions solving some/all of the Medium-Hard would also guarantee pass.

Every problem was solved during the contest by at least 1 team, congratulations to the teams that solved the harder problems!

DP was the most common topic it could be used in 6 of the problems, also for all DP problems (except L) they required a non-trivial transformation or optimization.

Notes on M: It was very hard, I think it was comparable in difficulty to https://open.kattis.com/problems/firstofhername. Would recommend finalists to solve this problem.

Link to editorial: https://github.com/Diego1149/ICPC-Latam-2020

For the difficulty in the editorial I assigned it based on the relative difficulty of the contest itself, meaning 1 to the easiest, 10 to the hardest.

Let me know if you have any questions or think I should update any of the editorials!

  • Vote: I like it
  • +35
  • Vote: I do not like it

»
3 years ago, # |
  Vote: I like it +23 Vote: I do not like it

Hack for your M solution.

  • »
    »
    3 years ago, # ^ |
      Vote: I like it +5 Vote: I do not like it

    That's true, thanks for noticing, I'll have to learn suffix array to be able to solve it properly :P

»
12 days ago, # |
Rev. 5   Vote: I like it 0 Vote: I do not like it

Problem B — Beautiful Mountains can be solved in a much easier way (in my opinion).

Preprocess for each index i, the largest index j so that (i, j) is non-decreasing. Do the same in reverse (so we get the data for the non-increasing indices). Each direction can be done in O(n) if you keep track of indices (of missing values, and biggest previous value, etc).

Using this precomputed data it's possible to compute in O(1) if a subarray is a mountain. Let $$$A[from:to]$$$ be a slice/subarray (indices are inclusive), then it's a valid mountain if $$$asc[from] >= desc[to]$$$.

Then we can try all possible mountain chains. Starting from $$$size = 3$$$, try all mountains and increase the subarray starting index with a step of $$$size$$$.

What's the complexity of doing this? The first chain does $$$\frac{N}{3}$$$ iterations, for the next size it does $$$\frac{N}{4}$$$, and so on, until the last size which does $$$\frac{N}{N}$$$ iterations. In total $$$T(N) = \frac{N}{3} + \frac{N}{4} + ... + \frac{N}{N}$$$, which can be written as $$$T(N) = N (\frac{1}{3} + \frac{1}{4} + ... + \frac{1}{N})$$$. The value inside the parentheses is the harmonic number (without the first two terms though), which is known to be around $$$ln(N) + C$$$ (C is some constant, but it doesn't really matter). So $$$T(N) \in \mathcal{O}(N log N)$$$.

Also your code has wrong answer for these cases (size N is the first integer in each line):

4 -1 -1 86 100

6 53 80 -1 99 9 34

Both should be "NO". I also got AC with some lousy programs by the way. Data seems weak.