omsincoconut's blog

By omsincoconut, 9 days ago, In English
Rating predictions

2261A - Hey, It's Me, Souvlakity

Author: SpyrosAliv
Preparation, Editorial: Marszpace

Hint 1
Hint 2
Solution
Code
Rate The Problem!

2261B - What's the Capital of France?

Author, Preparation, Editorial: omsincoconut

Hint 1
Hint 2
Hint 3
Solution
Code
Rate The Problem!

2261C - I Know About a Million Things

Author, Preparation, Editorial: Marszpace

Hint 1
Hint 2
Hint 3
Solution
Code (C++)
Rate The Problem!

2261D1 - Come Be My Friend, Don't Be So Scared (Easy Version)

Author, Preparation: omsincoconut Editorial:Proof_by_QED

Hint 1
Hint 2
Solution
Code
Rate The Problem!

2261D2 - Come Be My Friend, Don't Be So Scared (Hard Version)

Author, Preparation: omsincoconut Editorial:Proof_by_QED

Hint 1
Hint 2
Hint 3
Solution
Code
Rate The Problem!

2261E - What Does the Cow Say?

Author, Preparation, Editorial: yse

Hint 1
Hint 2
Solution
Code (C++)
Rate The Problem!

2261F1 - Plegma II: Ask Me Any Cell (Easy Version)

Author, Preparation, Editorial: SpyrosAliv

Hint 1
Hint 2
Solution
Code
Rate The Problem!

2261F2 - Plegma II: Ask Me Any Cell (Hard Version)

Author, Preparation, Editorial: SpyrosAliv

Hint 1
Hint 2
Solution
Code
Rate The Problem!

2261G - 1 2 3 and XOR, Where Did Everybody Go?

Author, Preparation, Editorial: chromate00

Hint 1
Hint 2
Hint 3
Solution
Code
Rate The Problem!

2261H - Oh Tree Tree Tree, No Need to Leave

Author & Editorial: SpyrosAliv
Preparation: SpyrosAliv & ttamx

Hint 1
Hint 2
Solution
Code
Rate The Problem!
  • Vote: I like it
  • +135
  • Vote: I do not like it

»
8 days ago, hide # |
 
Vote: I like it +5 Vote: I do not like it

In Problem D1 idk why i was trying to find the most optimal answer so bad that even though i got the solution, i was thinking that my solution is wrong and there must be a smaller number of sensor possible.

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

    i actually found the (n+2)/2 but didn't realise that i can get (n+1)/2. i realised that it is close to n/2. my pattern was correct but just 1 gap difference. was quite sad

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

Turtle speed editorial :O

»
8 days ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

I solved E like this, im trying to merge some run with some another run (of left brackets from left to right.) I keep a prefix sum of gain in longest length if i merge some runs (length of left run + length of right run — number of right brackets in between), then I use sparsetable to query the best answer for each run of left brackets building leftwards and I handle the first run of brackets differently since you dont lose a left bracket from an operation

»
8 days ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

I solved G without trie or any data structures: 395029892

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

    you used vector, that is a data structure

»
8 days ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

F1 can be solved with backtracking 395018997

Spoiler
  • »
    »
    8 days ago, hide # ^ |
     
    Vote: I like it +8 Vote: I do not like it

    I also firstly make S fixed, then I realize that if I erase 4k 1's then the removing direction wouldn't change. Thus I made a 4*4 block out of (r,c), repeating remove the grid into 4*n then 4*4. Only at the last operation on one side would erase 0 and change the direction. 395031077

»
8 days ago, hide # |
 
Vote: I like it -13 Vote: I do not like it

G best 800 SkyMagic speaks the truth

»
8 days ago, hide # |
 
Vote: I like it +30 Vote: I do not like it

On E, it is cool to think of the string as euler tour of the tree. Operation is then removing the leaf and creating new root for the tree.

»
8 days ago, hide # |
 
Vote: I like it +24 Vote: I do not like it

There is also an alternative solution to D2 that requires almost no thinking, although it has an extra $$$O(\log n)$$$ factor.

Spoiler
»
8 days ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

E was soo good to solve with making string a tree

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

can anyone explain the problem B

  • »
    »
    8 days ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it
    Spoiler (My solution)
  • »
    »
    7 days ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    suppose u are standing on the index of the max value and u have to increase the value of the left element or right element. so the optimal way to increase values is take the bit where the highest bit u have on and your neighbour off. on all the bits lower than it by increasing. for example take 24 and 18 the highest bit value 24 on and 18 off is 8 so greedly u will increase the 18 upto 23 so that u can get maximum or

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

    We want to maximize the bitwise OR of all elements in $$$A$$$.

    Let $$$M = \max(A)$$$ and $$$m = \min(A)$$$.

    Since an operation only increases the smaller element, $$$M$$$ never changes, and no element can exceed it.

    Ideally, we want to set all bits below the most significant bit of $$$M$$$ to $$$1$$$. For example, if $$$M = 42 = (101010)_2$$$, the ideal result would be $$$(111111)_2 = 63$$$.

    We can represent $$$k$$$ consecutive set bits using $$$2^k - 1$$$. However, we cannot always reach this ideal value because elements cannot decrease or exceed $$$M$$$.

    The key is to find the most significant bit where $$$m$$$ and $$$M$$$ differ. This bit determines how many lower bits we can set to $$$1$$$ while keeping the resulting number between $$$m$$$ and $$$M$$$.

    Let this bit be at position $$$k$$$. Since $$$m \lt M$$$, this bit is $$$0$$$ in $$$m$$$ and $$$1$$$ in $$$M$$$, while all higher bits are identical.

    We can increase $$$m$$$ to a value $$$x$$$ that preserves the higher bits, keeps bit $$$k$$$ equal to $$$0$$$, and sets every lower bit to $$$1$$$. This value satisfies $$$m \le x \le M$$$, so it is reachable.

    For example, if $$$m = 40$$$ and $$$M = 42$$$:

    $$$ \begin{aligned} M &= (101010)_2 = 42,\\ m &= (101000)_2 = 40,\\ x &= (101001)_2 = 41. \end{aligned} $$$

    Then

    $$$ M \mid x = 101011_2 = 43. $$$

    Since all bits below position $$$k$$$ are set to $$$1$$$ in the OR, no larger result is possible. Therefore, the maximum is

    $$$ \boxed{M \mid (2^k - 1)} $$$

    where $$$k$$$ is the most significant differing bit of $$$m$$$ and $$$M$$$.

    If $$$m = M$$$, all elements are equal, no operation changes anything, and the answer is simply $$$M$$$.

»
8 days ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Small typo in the F2 editorial: shouldn't the time complexity be $$$O(n^4)$$$, since we output $$$n^2$$$ grids, each containing $$$n^2$$$ cells?

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

can anyone explain why my solution is ac, this should give tle in my opinion :

https://codeforces.com/contest/2261/submission/395025142

i basically brute check how far left we can go starting from first ( of every ((((( block . i jumped block by block, but still i think test case can generated to make it n^2

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

I think $$$G \ll F2$$$

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

In Problem A, for s = 1100, the optimal will be both get 2 as their final score..

  • »
    »
    8 days ago, hide # ^ |
     
    Vote: I like it +3 Vote: I do not like it

    Since Kalamakity wants to minimize the score, no matter which integer Souvlakity gives him he will give it back. At the end, the score will be 1. Kalamakity does not care about his score, only Souvlakity's score being minimum.

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

      Thank you..I got it now..I didn't understand the problem statement correctly..I thought optimally as in a way both want their score to be higher and opponent score to be lower

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

I'm confused about the editorial for problem G. It seems that the approach used in the code is different from the one described in the written explanation.

»
7 days ago, hide # |
 
Vote: I like it +5 Vote: I do not like it

In D, why not consider the array a circle? That way you avoid having to thing about edge cases between the first and last positions, since they now become adjacent.

The motivation behind that is that intervals split the array in two: the part inside of it and the part outside of it. But those are just two circular arrays that complement each other, so if you think of the array as a circle, adding an interval is equivalent to drawing a line, and the detector responds whether the hidden position is to the left or to the right of the drawn line (and positions are obviously placed on the perimeter of the circle).

This way the construction for D1 becomes drawing a bunch of diameters until adjacents are distinguished (and diameters help distinguish everything).

Also with this notion I think it's easier to see the tree like structure for D2.

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

sample testcase for D1 could have been better.

»
3 days ago, hide # |
← Rev. 2  
Vote: I like it 0 Vote: I do not like it

I used some really rough methods in F1 to forcefully construct and discuss 9 situations—it totally exhausted me.