paulzrm's blog

By paulzrm, history, 3 weeks ago, In English

2256A-Three Numbers on the Blackboard Idea: paulzrm

Hint 1
Hint 2
Hint 3
Tutorial

2256B-Domino Tiles Idea: paulzrm

Hint 1
Hint 2
Hint 3
Tutorial

2255A-Hot Potatoes at the Fairy Warehouse / 2256C Idea: Error_Yuan

Hint 1
Hint 2
Hint 3
Tutorial

2255B-A Ribbon for Tomorrow / 2256D Idea: paulzrm

Hint 1
Hint 2
Hint 3
Tutorial

2255C-Even If the World Turns / 2256E Idea: paulzrm

Hint 1
Hint 2
Hint 3
Hint 4
Tutorial

2255D-How Long Until Nothing Remains? / 2256F Idea: Error_Yuan

Hint 1
Hint 2
Hint 3
Tutorial

2255E1-What Will Remain at the End? (Easy Version) Idea: paulzrm

Hint 1
Hint 2
Hint 3
Hint 4
Tutorial

2255E2-What Will Remain at the End? (Hard Version) Idea: paulzrm

Hint 1
Hint 2
Hint 3
Hint 4
Tutorial

2255F-Who Will Witness the End? Idea: paulzrm

Hint 1
Hint 2
Hint 3
Hint 4
Tutorial
  • Vote: I like it
  • +158
  • Vote: I do not like it

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

Auto comment: topic has been updated by paulzrm (previous revision, new revision, compare).

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

Lightning Fast Editorial, Thank you!!

Great contest imo, at least the problems themselves :)

»
3 weeks ago, hide # |
 
Vote: I like it +80 Vote: I do not like it

D1C was amazing

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

Great contest, I thought i did something wrong when i got that the answer for 2256B was <=4, lol

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

really fun contest to do! going to watch sukasuka because of this!

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

I personally switched from C to D when I observed two things that i found hard to combine: 1. there is a case when we have one black tile — i assume, it should be moved to the secret location 2. there is a case where all tiles but one are black — i assumed we should swap empty one with the target.

I think editorial accomplishes 1. but for 2. it does something else, right? Does it cut the "opposite" tile, whatever this means?

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

    I gave 1C and 1D the same score so that everyone could freely choose which problem to solve. I wonder how many contestants noticed this :-)

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

      Excuse me, did you get the idea of 1C from learning the representation theory of finite group?

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

    During the round I found it helpful for me to think of the special case where you put one black tile wherever you want, and then generalize that to $$$w$$$ black tiles. Then I kinda just went toward center of mass because it seemed like it would hold under the transformations and you can prove it does.

    I personally avoided the issue by saying that the "correct" version is the one with black cells $$$\le 50\%$$$ of the grid, and flipping them all if this condition is violated. Intended solution is even simpler, flipping doesn't change the center of mass at all.

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

At least I tried to solve a task with Chtholly using chtholly tree 386390995

Do you know how to improve operations 2 and 3 while keeping the chtholly tree idea?

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

    Sorry, but before the contest, I deliberately generated test cases to break the Chtholly Tree, since this data structure only works when the input is guaranteed to be random XD

»
3 weeks ago, hide # |
 
Vote: I like it +14 Vote: I do not like it

BinaryForces

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

    What you may not know is that the original Div. 2 A also took a binary string as input, but we eventually replaced it with another problem lol

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

great contest, thank you!

»
3 weeks ago, hide # |
 
Vote: I like it +12 Vote: I do not like it

While totally overkill, Div2B can also be solved with DP.

$$$dp[i][ld]$$$ where $$$i$$$ is the position and $$$ld \in [1,4]$$$ is the value of the last two digits at $$$i$$$ in binary. Transitions are just the ones where the sum between $$$s_{i-1}$$$ and $$$s_{i}$$$ is different from the sum between $$$s_{i-1}$$$ and $$$s_{i-2}$$$. For example, if I set the current digit to $$$0$$$, only transitions from $$$dp[i-1][ld]$$$ with $$$ld = 2 = 10_2$$$ and $$$ld = 3 = 11_2$$$ are possible.

386346044

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

    Yes. This was the way I solved the problem. The DP iteration formula also shows that the final answer is between 0 and 4 inclusively.

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

Can someone explain more about this modular center of mass. I can see that its not exactly same as the physical centre of mass. Coz shifting in a normal sense would move the Centre by the same delta, but if the shift is cyclic, it won't (physically).

Example : consider a 7 by 7 square, with first and last column fully black. Now the centre is at (3,3), now consider shifting it by +1 to the right, the physical centre moved by -2.5, but the modular one, accoring to the editorial, moves by +1. And now consider inverting colors also, pyhsically from (3,0.5) it should move to (3,5.5), but modularly acc to the edi, it doesnt change.

Also are there some other problems or anything relateed to this? ppl didn't just come up with this out of nothing i assume.?

But yeah, many many submission seem AI, all have same variable names, cx rx sc sr tc tr,

anyways, div2 D was cool.

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

    Shifts: You increased all the x coordinates (or y coordinates) by 1, so the center of mass shifts by 1 (with mod if needed). The actual center cell moves the same way.

    Rotations and reflections: Consider mapping $$$x$$$ to $$$n+1-x$$$. Then if the previous sum is $$$\Sigma x$$$, then the new sum would be $$$wn + w - \Sigma x$$$, which if you divide by $$$w$$$ becomes $$$n + 1 - \overline{x}$$$, which is exactly where the center cell moves as well.

    Inverting the colors: I bypassed this issue by saying that the "correct" picture is the one with less than half black cells. If there were more than half black cells then I would just flip it back.

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

    If you are looking for a graphical/physical sense of what the modular center of mass means, I don't think there is such intuition as there is for the non-modular center of mass. Consider that perturbing w or n slightly will completely change the center.

»
3 weeks ago, hide # |
 
Vote: I like it +61 Vote: I do not like it

In div.1 D you don't need to do binary search. In fact, if we denote $$$n+\max(\lceil\log a_i\rceil-i)$$$ (with $$$a_i$$$ sorted) as $$$h$$$, then $$$T=h+1$$$ is always sufficient, while $$$T=h-1$$$ is never sufficient. So, you only need to check if $$$T=h$$$ works.

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

Thanks for the fast rating update!

»
3 weeks ago, hide # |
 
Vote: I like it +69 Vote: I do not like it

I have an alternative derivation of the condition in the 2nd hint of D1D 2255D - How Long Until Nothing Remains?

Alternative Derivation
»
3 weeks ago, hide # |
 
Vote: I like it +5 Vote: I do not like it

Is no one going to acknowledge the fact that the editorial doesn't mention anything regarding the joke of printing answer mod 998244353 in 2256B.

»
3 weeks ago, hide # |
 
Vote: I like it +6 Vote: I do not like it

DIC is the most interesting problem i have ever seen concerning Congruence Algebra:)

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

Hurray! I got to reach expert in this contest. I target 4 div2 problems in each contest, and today i managed to solve them all.

But it somewhat feels like good luck, that i am able to solve them. Sometimes it happens that I am stuck on problem 3 and am completely blank.

Is it just me, or it happens to all of you guys too.

Moving from expert to CM feels completely impossible.

Please share advice and your experience — Senior Coders :)

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

386398944 can any one tell me why y randomization get tle The time complexity is o(22*30*n) == 2e8 which suppose pass in 2 sec

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

386398944 can any one tell me why my randomization get tle The time complexity is o(22*30*n) == 2e8 which suppose pass in 2 sec

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

In Div2 i think C was easier than B

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

D1C/D2E is interesting!

I think D1A&B&C/D2C&D&E are all great problems with intersting ideas :D

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

Is the sample output of div2 E incorrect? The answer for the first test case in the second run should be 2 5 instead of 1 1.

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

good cotest btw

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

Someone, please tell me how do i even approach problems like D, how do i even start, i was braining on DP solution to the problem , I want to solve D,because generally(6/10 times) it's not constructive while C is constructive almost every time.

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

    Yes, I thought DP until I saw that the operations can be applied onto each other. It's kind of like you make a prediction on how the problem will behave (like you guess that you can achieve every possible len > 1 of 0 blocks and 1 blocks using the given operation) and then you proof by AC??? Somebody who solved it pls explain how you arrived at the solution.

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

      well, the first idea is to transform the string into the array of numbers representing the lengths of the consecutive blocks $$$a$$$. then the thing i noticed is that an operation simply subtracts some $$$x$$$ from block $$$a_i$$$ ($$$x \lt a_i$$$ as there should be left at least one symbol) and adds that $$$x$$$ to another block $$$a_j$$$ (and $$$i \equiv j \pmod 2$$$ as the blocks must be the same color). therefore the number of blocks and the order(parity) cannot change, and our task is to count the number of distinct arrays $$$a$$$, which reminds me of the basic combinatorics problem stars and bars

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

Not really the best contest ever because the first 3 problems were like 800 — 1000 — 1000 and then immediately D was 1900 so RRRRIIIIIPPPPPP.

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

Upsolved Div1D and got AC with seemingly exponential set-packing solution but with pruning of possible masks 386546135 (if for all bit-prefixes, popcount of mask A is <= popcount of mask B, then we can prune B). I'm curious if this is just weak tests or there is some underlying reason the outstanding mask set can't grow too big.

EDIT: hacked

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

I like that the solutions to these problems are rigorous like actually showing that the invariants are enough to cover all cases rather than proving only that the invariants work. I think more editorials should do this.

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

C-physics>>?

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

My intution for Div2 D is count total no. of palindromes and subtract it from total no. of subarrays whose s[l] = s[r]. Can somebody explain why this giving wrong answer.

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

!?Data Structure!?

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

Can someone explain D1B please ty <3

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

peak cinema

»
2 weeks ago, hide # |
 
Vote: I like it -8 Vote: I do not like it

D2D/D1B. A Ribbon for Tomorrow

Operation: pick l ≤ r with s[l] == s[r], reverse s[l..r].

1. The block structure is invariant

Write s as maximal blocks: (1,o₁)(0,z₁)(1,o₂)(0,z₂)…

Reversing a subarray with equal endpoints never changes how many blocks of each character exist:

  • the endpoints have the same character, so no block merges/splits at the boundary;
  • inside, the blocks are only reversed in order, so their count is unchanged.

So the number of 1-blocks (k₁) and 0-blocks (k₀) is fixed forever, as are the totals cnt₁, cnt₀.

Example: 1100010 → 1000110 / 1101000 / 1100100 — always 2 blocks of 1 and 2 blocks of 0.

2. Sizes can be redistributed freely

Look at a piece (1,o₁)(0,z₁)(1,o₂), let s = o₁+o₂. Choosing the two 1-endpoints and reversing, we can reach every (1,1)(0,z₁)(1,s-1), (1,2)(0,z₁)(1,s-2), …, (1,s-1)(0,z₁)(1,1)

i.e. we can move 1s between adjacent 1-blocks while the 0-block between them is untouched. Symmetrically for 0s.

Example: 111001 → 110011 / 100111 — the 1s redistribute as 3+1 / 2+2 / 1+3, while the 0-block stays size 2.

Applying this to every adjacent pair, without loss of generality:

  • we can rearrange how the 1s are distributed among the 1-blocks however we like (each block needs at least one 1), independent of the 0-blocks;
  • and vice versa for the 0s.

So the sizes of the 1-blocks and the sizes of the 0-blocks are independent, and the only constraint is that every block is non-empty. Any such configuration is reachable, and reachable configurations are exactly these.

Counting : The answer is the number of ways to write cnt₁ as an ordered sum of k₁ positive integers, times the same for zeros — classic stars and bars:

$$$\binom{cnt_1-1}{k_1-1}\cdot\binom{cnt_0-1}{k_0-1}$$$
»
10 days ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Hi, can anyone please explain me the solution of the 2255F- Who will witness the end?

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

In D1C / D2E, I noticed that I must flush the output buffer after every test case, otherwise I'll get "Idleness limit exceeded" on the later testcases? Usually if this is the case for technical reasons, there'll be a paragraph in the problem statement pointing this out.