Блог пользователя awoo

Автор awoo, история, 5 месяцев назад, По-русски

2182A - Новогодняя строка

Идея: BledDest

Разбор
Решение (BledDest)

2182B - Новогодний торт

Идея: BledDest

Разбор
Решение (BledDest)

2182C - Производство снеговиков

Идея: Roms

Разбор
Решение (BledDest)

2182D - Украшение новогодней елки

Идея: BledDest

Разбор
Решение (Neon)

2182E - Новогодние подарки

Идея: BledDest

Разбор
Решение (Neon)

2182F1 - Рождественские олени (простая версия)

2182F2 - Рождественские олени (сложная версия)

Идея: Roms

Разбор
Решение (BledDest)

2182G - Короткая гирлянда

Идея: BledDest

Разбор
Решение (awoo)
  • Проголосовать: нравится
  • +99
  • Проголосовать: не нравится

»
5 месяцев назад, скрыть # |
Rev. 3  
Проголосовать: нравится -11 Проголосовать: не нравится

good contest

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +13 Проголосовать: не нравится

D > E?

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Real GOOD BYE!

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

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 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

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

  • »
    »
    4 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    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 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    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 месяца назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится 0 Проголосовать: не нравится

    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 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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 месяцев назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

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

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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 недели назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

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

  • »
    »
    3 часа назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

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

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

poor statement for F1 , though clear from examples .. They should clearly explain what is distinct grp , like whether size difference or ids of reindeer also matter .

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +24 Проголосовать: не нравится

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

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Very hard contest for me :(

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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 месяца назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится 0 Проголосовать: не нравится

    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 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Your strategy of computing binomial coefficients is incorrect.

    Why it is incorrect
»
4 месяца назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

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 месяца назад, скрыть # |
Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

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

Instead of the following
It should be this
»
4 месяца назад, скрыть # |
Rev. 6  
Проголосовать: нравится 0 Проголосовать: не нравится

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 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Really loved question D

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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

356437655

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    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 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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.

»
3 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

In Problem E

in editorial solution why we do that "reverse(ev[i].begin(), ev[i].end());" i don't understand can someone please explain it?

  • »
    »
    3 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    ev[i] consists of -1 ans z — y. Initially -1's that denote boxes are placed at the beginning. For each beutifullness we want to spend maximum amount of boxes (bc it costs zero additional money for us). Those boxes can be used on the current gifts of cost z — y or from lower levels. So first we put in the multiset all z — y and only after that pop some of them with -1's. The loop (int x : ev[i]) must first go over z — y's of the current level to add them into multiset. So for them to go first we reverse ev[i]. If we don't do it -1's would go first.