BledDest's blog

By BledDest, 15 months ago, In English

1879A - Rigged!

Idea: Roms

Tutorial
Solution (Roms)

1879B - Chips on the Board

Idea: BledDest

Tutorial
Solution (Neon)

1879C - Make it Alternating

Idea: Roms

Tutorial
Solution (Roms)

1879D - Sum of XOR Functions

Idea: Roms

Tutorial
Solution (Roms)

1879E - Interactive Game with Coloring

Idea: BledDest

Tutorial
Solution (BledDest)

1879F - Last Man Standing

Idea: BledDest

Tutorial
Solution (awoo)
  • Vote: I like it
  • +76
  • Vote: I do not like it

| Write comment?
»
15 months ago, # |
  Vote: I like it +5 Vote: I do not like it

Clear editorial!

»
15 months ago, # |
  Vote: I like it +1 Vote: I do not like it

Clear Editorial, but it should have appeared in a more clear place lmao

»
15 months ago, # |
  Vote: I like it +6 Vote: I do not like it

D was pretty fun

»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

There is a question on task D, why we don't take into account carry-over units from previous digits when counting the i-th bit? Thanks in advance.

  • »
    »
    15 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    There are no such carry-over units because it is the sum of XOR not plus(maybe)

    • »
      »
      »
      15 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Yes, I agree, but after XOR we also add them to each other and we have to take into account that the previous bits affect the current one

»
15 months ago, # |
  Vote: I like it +8 Vote: I do not like it

F was really fun

»
15 months ago, # |
  Vote: I like it +1 Vote: I do not like it

In D's editorial, if pref(x) is equal to the number of ones on the prefix of length x modulo 2, then for even number of ones, shouldn't pref(x) be 0?

  • »
    »
    15 months ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    Yeah, this is an error, thank you. Will be fixed in a couple of minutes

»
15 months ago, # |
  Vote: I like it -21 Vote: I do not like it

E is so cringe

»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

For anyone else struggling to formalize why their intuition for B leads to an optimal arrangement of chips:

The key insight is what the tutorial notes -- a valid chip arrangement must satisfy either (1) each row has at least 1 chip or (2) each column has at least 1 chip.

Now, we have two cases.

Say we have a valid chip arrangement that satisfies (1). Then, we can make an arrangement that is as cheap or cheaper by removing any extra chips so that each row has exactly one chip (vs. at least one). From here, observe that the cheapest 1-chip-per-row arrangement is the one you get by picking the cheapest column and filling each cell in it with a chip. Any other 1-chip-per-row arrangement is more expensive because there will be a chip in the same row, but a more expensive column.

Similarly, say we have a valid chip arrangement that satisfies (2). Then, we can make an arrangement that is as cheap or cheaper by removing any extra chips so that each column has exactly one chip (vs. at least one). From here, observe that the cheapest 1-chip-per-column arrangement is the one you get by picking the cheapest row and filling each cell in it with a chip. Any other 1-chip-per-column arrangement will be more expensive because there will be a chip in the same column, but a more expensive row.

  • »
    »
    15 months ago, # ^ |
      Vote: I like it +10 Vote: I do not like it

    Proof of the insight: Suppose that there is at least one row missing and at least one column missing. You can then pick a cell such that the cells location is (missing row,missing col) which isn’t covered.

»
15 months ago, # |
Rev. 2   Vote: I like it +9 Vote: I do not like it

In problem F, it's not necessary to use a sparse table. It is enough to store 2 maximums for every suffix and for a segment [l, r] we can take suff max on [l, a]. This works because if exist some hj >= hi, where l <= i <= r and j > r, we will get j's real value in a different segment and this value will be definitely greater than i's

  • »
    »
    15 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Oh, that's neat. Cool idea!

»
15 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Thanks to the authors for their work on this round :)

Here is my advice about the problems

A
B
C
D
E
»
15 months ago, # |
  Vote: I like it +3 Vote: I do not like it

Nsqrtn pass on F:225085205

»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

How are we colouring a bamboo (All nodes having one child except the last one) in E ?

  • »
    »
    13 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    By the explanation, it will use three colors. 1 2 3 1 2 3 ...

»
14 months ago, # |
Rev. 4   Vote: I like it 0 Vote: I do not like it

My approach on C: If we consider a maximal block of same character sequence of size say $$$l$$$ then the number of ways we can pick an element to survive in that block is $$$l$$$ ways, after which there exists $$$(l-1)!$$$ arrangements to delete the remaining elements in the block. Hence there exists a total of $$$(l - 1)! \times l = l!$$$ ways within the block to perform the valid operation. And if there are $$$k$$$ such blocks then there exists a total of $$$\prod_{i}^{k}l_{i}!$$$ valid operations.

This approach fails however, not sure why. Any help/corrections appreciated!

  • »
    »
    13 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Did you figure it out?

    • »
      »
      »
      13 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I just thought of a counter example: 0011 expected answer: 8 because n-k = 2 -> 2!*2*2 = 8 The solution you provided is 4. Still not sure why it doesn’t work

      • »
        »
        »
        »
        13 months ago, # ^ |
        Rev. 2   Vote: I like it 0 Vote: I do not like it

        So after thinking for a bit your solution only computes the number of ways to permute each group, in other words, the number of ways you can pick a number from each of the groups. It doesn’t take into account that you can select numbers from different groups before fully finishing one group (I don't know if that makes sense).

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

Can someone please explain why the time complexity in D comes out to be nlogA? Shouldn't it be n^2logA?

We are going from l=1 to r for every r; that means (n^2)/2 linear time operations employing n^2 time complexity. Am I wrong some where?

»
8 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Hey can any one help me out here, getting WA on testcase 6 for Problem D submission

  • »
    »
    7 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Heh Solved it with new dp approach smirking check out this 263789195

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

      can u explain ur dp approach?

      • »
        »
        »
        »
        3 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        hey,for every bit i I created a binary array, where arr[x] is set if xth elements ith bit is set,then did some dp over that array (now i don't really remember exactly what i did back then but ) here first my aim was to calculate just f(l,r) on for every l,r possible on that binary array so lets say there are count number of pairs with xor set.answer contribution would be (2^i)*count , where i is ith bit of array , after that slight modification would add r-l+1 factor as well (initially my dp state was something like counting pairs with set and unset pretty easy transition. form there i moved toward solution)

    • »
      »
      »
      4 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      293544056

      hi, help is appreciated considering my dp is correct for individual bits... what am i doing wrong for integrating contribution of each bit in my final answer..?

  • »
    »
    4 months ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    I used a similar approach, check this once 276079653

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Sorry for necroposting, but in problem C can anyone explain that why changing of indices of other characters (after deleting some character) does not effect the answer?

Thanks

  • »
    »
    2 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    This part of the editorial makes it clear. So even if we delete the char and index, the number of ways remains the same.

    For example, let's consider that the string s=001100 and the chosen indices to erase are 1, 4 and 5. Then there are 3!=6 ways to choose the order of them:

    1, 4, 5; 1, 5, 4; 4, 1, 5; 4, 5, 1; 5, 1, 4; 5, 4, 1.

»
3 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

I'm little bit confused about the editorial of Problem-