BledDest's blog

By BledDest, history, 13 hours ago, translation, In English

2242A - Bigrams

Idea: BledDest

Tutorial
Solution (BledDest)

2242B - Predominant Frequency Division

Idea: FelixArg

Tutorial
Solution (FelixArg)

2242C - Unstable Elements

Idea: BledDest

Tutorial
Solution (BledDest)

2242D - Two Digit Strings

Idea: Roms

Tutorial
Solution (BledDest)

2242E - Product of Closures

Idea: adedalic

Tutorial
Solution (adedalic)

2242F - Summer Vacation

Idea: FelixArg

Tutorial
Solution (FelixArg)
  • Vote: I like it
  • +55
  • Vote: I do not like it

»
12 hours ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

How cooked am I if my first thought to solving B is range update range query

Spoiler
Or
  • »
    »
    11 hours ago, hide # ^ |
     
    Vote: I like it +3 Vote: I do not like it

    Not as cooked as me when I solved Div.2 C by directly constructing string of length $$$10^{18}$$$ with persistent treap :D

    57378448 (7 years ago, damn)

    • »
      »
      »
      9 hours ago, hide # ^ |
       
      Vote: I like it -6 Vote: I do not like it

      I still don't know what a treap is :sob:

»
11 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

How to solve C if the array is not sorted?

  • »
    »
    9 hours ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Technically the array doesn't need to be sorted, since the condition was for a[i] != a[i-1], not a[i] > a[i-1], meaning that same numbers had to be grouped next to each other. Something like 1 1 1 5 5 3 3 3 2 2 9 9 7 7 7, which you can easily count the number of marked elements for.

    For arrays in which same numbers aren't grouped together, for example like 1 3 5 2 3 1 4 3 1 5, you can just treat every element as a different group

»
11 hours ago, hide # |
 
Vote: I like it +5 Vote: I do not like it

did anyone solve problem F using std::rope? My solution is 7 lines, but unfortunately the relatively low time limit and std::rope having a terrible implementation means it TLEs even with periodic rebuilds. (even O(nsqrt(n)) block decomposition implementation is faster)

code
»
11 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Extremely hard B

»
10 hours ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

D was a good problem though. In contest I did not recognize how to transform such a hard problem into an easy one. Great job, authors.

»
10 hours ago, hide # |
Rev. 2  
Vote: I like it +3 Vote: I do not like it

In Problem C, I missed the fact that the array was sorted. I ended up using DSU to connect the gaps, overcomplicating the solution that took more than 60 minutes during the contest. Here's the solution.

»
9 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

what a cool solution for D... I honestly thought it was subsegment DP or smth

»
9 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

The B was very difficult to solve .

»
8 hours ago, hide # |
Rev. 3  
Vote: I like it 0 Vote: I do not like it

damm! nice solution for d observing the opertaion on prefix sums very good!!!i did not gain any elo but at first div3 were like heaven to me lots of learning now education div2 are heaven lots of learning hope someday div2 will be heaven then div1 too.... Love your contests and the way you teach in editoriLs BledDest love it !!

»
7 hours ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

I would love to learn from someone if they have approaches for D different from the editorial

  • »
    »
    6 hours ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    My idea doesn't use prefix sums,

    First, lets consider when the answer is -1. As we can see, each operation doesn't change the sum of digits in a number modulo $$$10$$$.

    Lets follow this idea a little, we consider some consecutive pairs of digits that we will never do an operation on(in both numbers). These pairs separate both digits into "blocks", that, after applying all operations will become single digits. As we can see, the goal in this task, is to separate those 2 numbersinto the same (maximum) number of blocks, where the blocks have the same sums modulo $$$10$$$ (i mean the first block in s1, has the same mod sum as the first block in s2 and so on).

    Let $$$dp(i,j)$$$ be the maximum number of blocks that we can divide the prefix of length $$$i$$$ in $$$s1$$$, and the prefix of length $$$j$$$ in $$$s2$$$, it is easy to calculate this (you would have to consider $$$O(n)$$$ blocks) $$$dp$$$ in $$$O(n^3)$$$ time.

    But fortunately, there is an optimization, consider the index $$$i$$$, and the maximum $$$l$$$ such that $$$l \leq i$$$, and $$$\sum_{j = l}^{i}{s_j} \equiv d \pmod{10} $$$, where $$$d \in$$$ { $$$0,1 \dots, 9$$$ } where $$$s$$$ is either $$$s1$$$ or $$$s2$$$, it doesn't matter for this optimization. let $$$l_1$$$ be the maximum index such that $$$l_1 \leq l$$$, and $$$\sum_{j = l_1}^{i}{s_j}$$$, as you can see, $$$\sum_{j=l_i}^{l-1}{s_j} \equiv 0 \pmod{10}$$$, so we can simply consider the smallest block with the sum, and don't worry about the rest.

    submission : 381524391

»
6 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I like how B is rated 881 on clist, because its definitely a 900 level problem. Sure, i mean prefix and suffix arrays were historically 1200 level concepts. But surely theres nothing fishy going on here, right? I guess everyone just got 300 points better

»
4 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Thanks for the amazing problems, but I like to point out that the problem F constrained with 1.5 second actually lets through a brute force solution with vectorization. Was this intentional? I was shocked to read the problem and finding it easier than B (the wording could have been simpler for B and C).

»
3 hours ago, hide # |
Rev. 4  
Vote: I like it +3 Vote: I do not like it

Problem 2242E - Product of Closures was fun. I couldn't figure out all the edge cases during the contest, but managed to solve it afterwards with a simpler but less efficient solution that runs in $$$\mathcal{O}(n \log^2 r)$$$ per testcase. With up to 1000 cases per test it's kind of pushing it, but apparently it still runs in under 1 second: 381658269

The idea is simple:

solution for problem E

I have no idea if this approach was considered and supposed to pass. The main benefit is that you can find this solution by optimizing the bruteforce solution, without doing any of the complicated casework.

»
119 minutes ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

How can I copy a subtree (e.g. $$$\color{blue}{4}, \color{blue}{5}, \color{blue}{0}, \color{blue}{1}$$$) and move them to two different positions within feasible time complexity in question F.

»
60 minutes ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Solve E in $$$O(Tn\log^2V)$$$ too,and failed on system test.

I heard that there're only 6 weak pretests in problem E,which was misleading.