__baozii__'s blog

By __baozii__, history, 39 hours ago, In English

We hope you enjoyed the problems!

Rate the contest!

2245A - Who Watches the Watchpig?

Solution
Code
Rate the problem!

2245B - Delete and Concatenate

Solution
Code
Rate the problem!

2245C - MEXOR

Solution
Code
Rate the problem!

2245D1 - Construct an Array (Easy Version)

Solution
Code
Rate the problem!

2245D2 - Construct an Array (Hard Version)

Solution
Code
Rate the problem!

2245E - Tom and Jerry

Solution
Code
Rate the problem!

2245F - Familiar?

Solution
Code
Rate the problem!

2245G - NPC Challenge

Solution
Code
Rate the problem!

2245H - Connect Connect See

Solution
Code
Rate the problem!
  • Vote: I like it
  • +67
  • Vote: I do not like it

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

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

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

    There seems to be some rendering issue with the tutorials. I am trying to fix it.

  • »
    »
    12 hours ago, hide # ^ |
    Rev. 3  
    Vote: I like it +19 Vote: I do not like it

    Edit: The editorial seems to be rendered correctly, I guess this comment is useless now.

    I somehow figured out that the syntax for editorial is [tutorial:(problem index)], so this is the editorial (which was written by __baozii__ of course) for anyone who need (including me lol)

    A:
    B:
    C:
    D1:
    D2:
    E:
    F:
    G:
    H:
»
12 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Fast editorial!

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

Sorry my bad i clicked the register button

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

wa on tc 17 is basicly AC, can i have points?
Face Image

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

The tutorial didn't render correctly, can you fix it please __baozii__?

Edit: maybe the bug is happening only for me

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

Damn D was graph?? never even thought of thinking graph for this.

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

C was a good problem despite i couldnt solve it

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

Absolutely amazing contest omg fire job

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

weird problems, D1 was fun to solve though

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

D was so good

Solved D1 with topological sort, couldn't get D2

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

    For D2, you can do a topological sort similar to D1, but using $$$a_i$$$ and $$$-a_i$$$ rather than $$$|a_i|$$$.

    Since if there exists a solution, there exists one where all values of $$$a_i$$$ and $$$-a_i$$$ are distinct and non-zero, you can build a graph with $$$2n$$$ nodes and each constraint gives some strict inequalities between $$$a_i$$$ and $$$-a_j$$$. Once you get a topological sort, whether $$$a_i$$$ or $$$-a_i$$$ appears first tells you whether $$$a_i$$$ should be positive or negative, and you get a solution.

    Funnily enough this was the way I solved D1 as well.

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

How can C be solved?

I solved it using XOR basis.

what is the easier approach?

  • »
    »
    12 hours ago, hide # ^ |
    Rev. 4  
    Vote: I like it +1 Vote: I do not like it

    Notice that every sequence f satisfying following conditions is valid:

    • f(i) <= i+1
    • f(i+1) >= f(i)
    • f(n-1) = n
    • 0 <= f(i) <= n

    so you can construct f backward, set f(n-1) = n and place every digit in binary representation of k xor n to f(n-2), f(n-3) and so on, then construct corresponding permutation p.

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

Could anyone explain why sorting is used in the official solution for Problem B? The second operation clearly states we can only pick two adjacent elements, which literally refers to elements next to each other in the original array, right? If pairings are restricted to adjacent elements only, sorting the entire array and rearranging its order should not be valid at all. Is there a misunderstanding of the problem statement here?

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

    You can consider it as having some 'negative' numbers (which you want to pair), and some 'positive' which you don't mind pairing. As long as there are at least one of each kind, you can also find an adjacent pair of such as well -- therefore, you don't need to care about their ordering but just about their count(s).

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

    Yes you can only do adjacent pairings. However, you can always construct an order of operations such that you can use the bigger half of the elements as the max. Imagine marking every element as 1 if it's in the bigger half of the elements, and 0 otherwise. No matter what, there is always a 1 next to a zero, and we can remove both.So you can always achieve using the biggest half of the array.

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

    Suppose you mark some elements as 0 and others as 1, and declare that each paired operation removes exactly one of 0 and 1. Then as long as 1 <= number of 0s <= number of 1s, you can always find an adjacent pair regardless of order.

»
12 hours ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Solved D1 1 minute after contest :<( bruuh

ConstructiveForces

»
12 hours ago, hide # |
 
Vote: I like it -7 Vote: I do not like it

D1 can be solved in really stupid ways (like sorting by number of non-negative sums) that don't generalise well for D2. I'm surprised the points' split was so much in favour of D1.

»
12 hours ago, hide # |
 
Vote: I like it +13 Vote: I do not like it

guessforces

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

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

»
12 hours ago, hide # |
 
Vote: I like it -39 Vote: I do not like it

Propose multiple constructions and pure-guess problems won't make your reputation be more positive.

Sincerely to every author who have the very bottom-line sympathy to participants.

  • »
    »
    12 hours ago, hide # ^ |
     
    Vote: I like it +64 Vote: I do not like it

    Do I propose contests to make my reputation more positive? I author problems because I love authoring problems. I want to share them to the community.

    Simply because problems C and D are constructive or problem B is greedy does not make the contest "multiple constructions and pure-guess problems". Is your definition of competitive programming purely data structures?

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

      I suspect that MaxBlazeIceInk (as well as I) doesn't like the variance that increases with tasks like C or D.

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

    Hug you,my honey,MaxBlazeIceInk,Hope your journey in the algorithm competition goes smoothly.

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

guessforces

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

What's the purpose of setting memory limit of problem F to 128 mb? don't think there's much difference, since it only prevent using int[500][500][500].

Also O(n^4) solution can actually pass.

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

Was a massive fan of problem A!

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

Did anyone else solve B this way?

if i take two elements say , a,b then its either max(a,b)-c or a+b-2c so given that max(a,b)-c>a+b-2c has to satisfy,then c must be greater than the min of the both, so all the values smaller than c must be somewhere matched with greater than c , so it will pair up and so on and did some other proofs to get to the final sol.

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

Hell, I think the solution to G seems pretty AI-generated.

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

Could someone explain the proof of the lemma in D1 in more detail? I didn`t understand it

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

    The point they're trying to make is that $$$\lvert a_i \rvert = \lvert a_j \rvert$$$ for $$$i \neq j$$$ can always be avoided.

    An easier way to show this is to bend the rules of the problem a bit and allow for decimals. Suppose that for some valid solution $$$a$$$, we have $$$\lvert a_i \rvert = \lvert a_j \rvert$$$ for $$$i \neq j$$$. Simply add $$$0.1$$$ to $$$a_i$$$. This will keep all non-negative restrictions sound as the sum increases, and no negative restrictions will be broken as $$$0.1$$$ is not enough of a change to go from a negative integer to a non-negative integer.

    Since there's an infinite number of decimals between any two integers, we have plenty of freedom in selecting small offests to satisfy all of the conditions.

    Now just convince yourself that these decimal values could in fact be scaled up to integers with the correct power of 10.

    The editorial follows this idea, but uses carefully chosen integer offsets instead.

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

Thank you for the wonderful contest!

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

Alternate solution to C with no casework on K:

If the MSB of $$$(k\oplus n)$$$ is greater than the MSB of $$$(n-1)$$$, then no possible permutation can make the MSB of $$$(k\oplus n)$$$ appear in the final xorsum, so the answer is no.

Otherwise, consider the binary representation of $$$(k\oplus n)$$$. If the $$$i$$$-th bit from the left of $$$(k\oplus n)$$$ is set, mark $$$2^{i-1}$$$ as a "used element". Additionally mark $$$0$$$ as a used element. Then, output all the non-used elements, then the used elements in order.

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

D2 and E are really good problems, enjoyed them so much.

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

This round will always be special for me.. it got me to Pupil! Huge thanks to __baozii__ for such a wonderful set of problems...

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

nice contest, loved D2 and E <3

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

The D2 of doom and despair.

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

Can someone please explain in detail how to solve B?

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

    First, subtract $$$c$$$ from each $$$A_i$$$. Suppose there are now $$$a$$$ nonnegative numbers and $$$n-a$$$ negative numbers.

    We consider two cases. If $$$a \ge n-a$$$, then there must be a nonnegative number adjacent to a negative number. We can delete the pair and obtain a nonnegative contribution. In the end, we can always collect all nonnegative contributions, so we only need to calculate the sum of all nonnegative numbers.

    Now consider $$$a \lt n-a$$$. We are inevitably forced to include some negative numbers. We reduce this case to the previous one. First, we delete some negative numbers and take their contributions. If we delete $$$k$$$ negative numbers, then we need

    $$$ a+k \ge n-a-k, $$$

    so

    $$$ k \ge \left\lceil \frac{n-2a}{2} \right\rceil. $$$

    Therefore, we take all nonnegative numbers together with the $$$k$$$ largest negative numbers, which solves the problem.

    Translated by ChatGPT

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

Reduce D to 2-SAT:

Let true represent positive and false represent negative. For each $$$i$$$, $$$j$$$, if $$$o = 1$$$ then at least one of $$$i$$$ or $$$j$$$ needs to be positive, so add a $$$i \lor j$$$ clause, and similarly if $$$o = 2$$$ then at least one of $$$i$$$ or $$$j$$$ needs to be negative, so add a $$$\lnot i \lor \lnot j$$$ clause. Then if this formula is satisfiable we have the signs and can do the topological sort.

The solution is effectively the implication graph of 2-SAT anyways, but this was a nice way for me to overcomplicate the problem and forget how my 2-SAT template works and then not get it correct until 20 seconds after the contest ended.

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

F drove me crazy!

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

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

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

I often recall the past.

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

Implemented Recursion on B and got MLE TwT

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

Waiting for H, as always!