awoo's blog

By awoo, history, 5 months ago, translation, In English

2182A - New Year String

Idea: BledDest

Tutorial
Solution (BledDest)

2182B - New Year Cake

Idea: BledDest

Tutorial
Solution (BledDest)

2182C - Production of Snowmen

Idea: Roms

Tutorial
Solution (BledDest)

2182D - Christmas Tree Decoration

Idea: BledDest

Tutorial
Solution (Neon)

2182E - New Year's Gifts

Idea: BledDest

Tutorial
Solution (Neon)

2182F1 - Christmas Reindeer (easy version)

2182F2 - Christmas Reindeer (hard version)

Idea: Roms

Tutorial
Solution (BledDest)

2182G - Short Garland

Idea: BledDest

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

»
5 months ago, hide # |
Rev. 3  
Vote: I like it -11 Vote: I do not like it

good contest

»
5 months ago, hide # |
 
Vote: I like it +13 Vote: I do not like it

D > E?

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

this test case in Problem E : 2 7 15, 5 6 7 3 5 6 6, 5 8 10, 5 6 8 , ,i didnt get it why the output should be 2 not 0

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

Real GOOD BYE!

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

x=z−b0 be the number of people who will not hang decorations during this round. If x<0, there are too many decorations in the 0-th box, and z people cannot hang them all. In this case, there are no fair permutations either.

i don't see this condition ever occur BledDest

i even submitted editorial sol'n without that condition and worked well

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

    yeah,i also think the same cz we can always pick the decorations in the zeroth box (untill we are finished ofc).

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

    not only it does never occur but i think it is also logically wrong because if you have more a[0] than "needed" then you can just keep picking decorations from a[0], until you finish all of them. I wonder if it is possible to hack that solution given "bad |= a[0] > z;".

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

    Yeah, looks like this condition is redundant in this implementation of the solution. I think it remained from the previous implementation, where some other check was missing and this condition was needed in its place.

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

    SanathK, your argument is correct. In fact, it's kinda too good case where we've support (a[0]) more than required (for smaller a[i]s). And as mentioned by few users as well, once all a[i]s have been exhausted, we can keep exhausting a[0] until done. I needed to reiterate back my solution once I read the editorial, then realized that it's logically correct to have this situation.

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

do editorials for educational round usually come out this late only?

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

How did 9k people even solve C ? Am i missing something ? what the hell bro. Skipped my Dinner for this contest.

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

    same i got 2 tle.

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

    i think you are missing that you use java (runs slow), i recommend using c++

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

    If you had written a brute force solution and checked the array like all i possible for a given j then you would have found that it is same for all j and similarly for k and from there you could have gotten that idea that you only need to calculate it once. Sometimes writing brute helps :)

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

Its crazy that the first 5 questions did not anything require anything like graphs or proper DP and could be solved with usual solving techniques. W contest but still htf are their so many solves on C and D mannn!!!!

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

Is it possible to do C in less than O(n^2)?

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

Before, you could become a pupil by solving A and B, but now there are too many cheaters. Now you need to solve A, B, and C , I don’t support cheaters , I hope in 2026 cheaters will be less than 2025 , welcome 2026

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

The problem C was overall good problem but I don't understand why the test cases were so strict for it. I had a different approach which was based on hashing but it was too slow because the constraints were strict. I had to use policy based hash tables which I wasn't aware of to get AC. You can find my submission here 355786375

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

    i think you just had to use a custom hash. unordered map will almost always get targeted in test cases

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

    iiit banglore damnnn u must have crazy rank in jee..

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

Nice contest. D was tough but i managed to get it :D

»
5 months ago, hide # |
 
Vote: I like it +24 Vote: I do not like it

i don't know why D $$$n \le 50$$$

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

Am I like the only person who could solve D but not C?

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

Very hard contest for me :(

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

im still perplexed on the thing that in the D you had to take inverse modulus in order to get the correct answer . I calculated NcR correctly , but since i didnt take inverse modulus(i divided by searching a multiple of each denominator in the numerator) i got wa on 3rd test. BledDest please look into the test cases . you can see my submission too .

the accepted one -> 355954390

the wa on third test case one -> 355950951

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

    I don't have an answer to your question unfortunately, but I was wondering if you could help me understand the solution implementation.

    The solution gets the final answer by computing

    f[z]*f[n-z+x]*inv(f[x])

    where f[n] is n!

    but the combinatorics states that the answer is:

    f[z] * inv(f[x]) * inv(f[z-x]) * f[x] * f[n-x]

    But I don't see how these two are equal.

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

    Your strategy of computing binomial coefficients is incorrect.

    Why it is incorrect
»
4 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

My approach to problem D:

You can reduce the problem to creating a matching between $$$Q = [q, q, \ldots, q, q+1, q+1, \ldots, q+1]$$$ and $$$A = [a_1, a_2, \ldots a_n]$$$ (WLOG assume $$$a$$$ is sorted), such that every element $$$Q$$$ maps to an element that is $$$\leq$$$ it in $$$A$$$. Iterate from right to left in $$$a$$$. For $$$a_i$$$, pick an element from the suffix of $$$Q$$$, among the elements that are $$$\geq a_i$$$ -- the answer will end up being a product of $$$n$$$ numbers.

Maybe this approach is overkill, but it was short to code (and intuitive for me personally when I tried the problem). It can be generalized to a setting where you want to count matchings between $$$Q$$$ and $$$A$$$ where $$$Q$$$ could have more than two distinct elements https://mirror.codeforces.com/contest/2182/submission/356026194

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

awoo I think there is a typo in editorial of Problem F1/F2,

Instead of the following
It should be this
»
4 months ago, hide # |
Rev. 6  
Vote: I like it 0 Vote: I do not like it

Hello

(Someone else has pointed out and I didn't notice, but I don't know how to delete my comment)

For problem D I didn't understand why the editorial code made the check b0 > z, to see if there are more gifts on box 0, compared to the people who dont have any left decorations on the last round.

Suppose we are on the last round and b0 > z. If the gifts on box 0 are more, then by playing two more round we can finish the decorations and the permutation is fair, a contradiction since we conjectured we are on the last round. So, in the last round, b0 <= z by default.

I commented out this check, and the code passes all the test cases. Am I missing something?

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

Really loved question D

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

Hello, Does someone have a hint or some code on how to solve D by DP? I find the combinatorial solution pretty inuitive but I guess less generalizable than a DP approach can be. Thank you

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

Can someone tell me what's wrong with my solution i can't tell at all ):

356437655

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

problem G

the last visited vertex in the subtree must be at a distance of no more than k−1 from v Let dp[v][k] store the number of ways to traverse the subtree of vertex v such that the last visited vertex is at a distance exactly k ** from v**

Doesn't it is typo?

I did't catch. If we have the distance less than k-1 by the condition 1 how it could be k?

:thinkng

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

    Why we need to multiply by the factorial of the number of remaining children to fix their order to the last child?

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

Dear Codeforces Team / awoo,

I am writing to appeal the plagiarism flag on my submission [355739601] for Problem 2182E.

My solution was flagged as coinciding with other participants. I firmly assert that I wrote this code independently. The similarity arises because the problem relies on a standard and widely known technique: Greedy with Regret (using a Min-Priority Queue).

This approach is the standard solution for this class of problems, most notably seen in Problem 1526C (Potions). The logic dictates a specific implementation structure:

Sort the available resources (in this case, boxes and friends).

Iterate through the requirements.

Use a Priority Queue to track "costs" taken so far.

If a constraint is hit, swap the current element with the minimum element in the PQ if it improves the result (the "Regret" step).

Because this is a standard template for this specific type of greedy problem, the structure of the if/else block and the Priority Queue operations will inevitably look identical across many correct submissions. There are very few distinct ways to implement this exact logic efficiently.

Furthermore, there are distinct implementation details in my code that prove independent authorship:

My code uses a custom struct Friend to manage the data, whereas the conflicting codes (e.g., Yugam2508) utilize vector<pair<int,int>>.

My variable naming and I/O handling are distinct.

The coincidence is strictly algorithmic due to the standard nature of the "Greedy with Regret" pattern, not due to sharing code or using a common unauthorized source during the round.

I kindly request that you review these structural differences and the standard nature of the algorithm used.

Thank you for your time and fairness.

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

In D, It is not possible for the condition $$$z \lt b_0$$$ to hold. Because, then it can go for one more round i.e $$$k$$$ will increase by 1.

Submission removing that condition from the editorial code — 357421945.

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

    Exactly. I had been thinking for 1 hour here thinking how can $$$z$$$ be $$$ \gt b_0$$$ after decrementing $$$b_i$$$ by $$$k$$$. Your submission that was accepted likely means that the editorial writer overlooked that detail.

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

Could somebody explain to me why in problem D, $$$b_0 \lt 0$$$ would mean that no permutation is fair? Couldn't it be swapped out for a bigger number and thus allow enough decoration for other boxes that couldn't quite make it upto $$$k$$$? Also, I don't think $$$b_0$$$ would ever be greater than $$$z$$$. Could somebody help me out see $$$b_0$$$ being $$$ \gt z$$$ in some cases? I have been thinking for 1 hour so far, but couldn't come up with answers.

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

I just bashed the sub-problem in G by maintaining the dp arrays of all the vertices in disjoint lazy segment trees that I lazily expanded, only to realize while in the middle of my implementation that the lazy updates that necessitated their use took the form of "multiply every element with some value", which can be handled in a far simpler manner without segtrees like in the editorial lol.

Surprisingly, my "naive" solution runs in just 515 ms.