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

Автор Ecrade_, 17 месяцев назад, По-английски

We apologize for the late editorial.

2090A - Treasure Hunt
Idea: _Lucien

Solution
Code

2090B - Pushing Balls
Idea: Ecrade_

Solution
Code

2090C - Dining Hall
Idea: myee

Solution
Code

2089A - Simple Permutation
Idea: QuietBeautifulThoughts

Solution
Code

2089B1 - Canteen (Easy Version)
Idea: Ecrade_

Solution
Code

2089B2 - Canteen (Hard Version)
Idea: Ecrade_

Solution
Code

2089C2 - Key of Like (Hard Version)
Idea: SpiritualKhorosho

Solution
Code

2089D - Conditional Operators
Idea: E.Space

Solution
Code

2089E - Black Cat Collapse
Idea: abruce

Solution
Code
Разбор задач Codeforces Round 1012 (Div. 1)
Разбор задач Codeforces Round 1012 (Div. 2)
  • Проголосовать: нравится
  • +13
  • Проголосовать: не нравится

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

Lightning fast editorial

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

Anyone has a better explanation for 2089A — Simple Permutation ? I don't really follow the solution.

Like why we want to find a prime between between $$$\lfloor \frac{n}{3} \rfloor$$$ and $$$\lceil \frac{2n}{3} \rceil$$$ (instead of $$$\lfloor \frac{n}{4} \rfloor$$$ or $$$\lfloor \frac{n}{2} \rfloor$$$)? And where is this $$$p, p-1, p+1, p-2, p+2, \dots$$$ from? What's the intuitions behind them?

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

    The idea is, for example if $$$n = 12$$$, We can make permutation $$$(5,4,6,3,7,2,8,1,9,10,11,12)$$$ so that $$$c_1 = c_3 = c_5 = c_7 = c_9 = 5$$$.

    The intuition is we want to find a prime $$$p$$$ close to the midpoint $$$n/2$$$, then construct the pattern $$$(p, p-1, p+1, p-2, p+2, ... )$$$ until it touched $$$0$$$ or $$$n+1$$$. Such pattern makes $$$c_1, c_3, c_5, ...$$$ all equal to $$$p$$$,

    It can be shown that if the chosen $$$p$$$ is close enough to the midpoint $$$n/2$$$, that is, between $$$\lfloor \dfrac n3 \rfloor$$$ and $$$\lceil \dfrac{2n}3 \rceil$$$, then the constructed pattern will be long enough that at least $$$\lfloor \dfrac n3 \rfloor - 1$$$ elements of $$$c$$$ will be equal to $$$p$$$.

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

Div2E/Div1B (easy version) — I solved with 2 pointer on buffs, love that.

Really good problems.

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

Thanks for the editorial.

I was looking forward to div 1 C1 but it seems missing. Are you planning to add solution for it? 2089C1 — Key of Like (Easy Version where k=0) For folks who struggled with the easy version, the solution analysis for the hard version is quite hard to follow

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

    Here is my approach. When $$$k = 0$$$, the keys and locks are in the same position, so the optimal chose can be seen as just trying to open the same lock. Thinking with the idea of generating function, you can find for the last $$$i-th$$$ lock, the formula is $$$\frac{1}{i}\sum_{k=1}^{i}z^k$$$ ,where the exponent of $$$z$$$ indicates the turns and the coefficient indicates the possiblity of openning a lock in this turn.(Don't forget to multiple former polynomials) And you can see that there is a loop in the turn so you can just let $$$z^n = 1$$$, thus, you can calculate directly the answer as $$$\sum_{i=1}^{l}\prod_{j=1}^{i} \frac{1}{l-j+1}\sum_{k=1}^{l-j+1}z^k$$$ and the coefficients will be the answer.(Note that the coefficient of $$$1$$$ will be the answer of the n-th person) The time complexity will be $$$n^2l$$$.

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

      can you explain how the formulas work(why they help us calculate the answer)? i tried asking chatgpt for help but i didn't quite understand, and i find this 2.2k problem very intriguing.

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

        Let's take $$$l=3,n=3$$$ for example.For the first lock, the possiblity of making the lock open in $$$1,2,3$$$ turn(s) will be the same, which is $$$\frac{1}{3}$$$. So, as I mentioned above, we make the exponent for the turns and the coefficient for the possiblity for exactly end at which turn. So you can note that for the first lock,the formula will be $$$\frac{1}{3}z+\frac{1}{3}z^2+\frac{1}{3}z^3$$$. Which means for the first lock,there is a chance of $$$\frac{1}{3}$$$ to end at exactly the first,second and the third turn,and no chance for turns else.And then for the second lock, we should calculate base on the first lock's formula, this is becase we only discussed turns costed for this lock,but how about which turn we are now at? Just mutiply the second turns formula and the first turns formula. And after expanding it,you can see that exponent adds and the possiblity multiplies, which is just like what we are going to calculate for(Do the expanding yourself to feel it). It will be $$$(\frac{1}{3}z+\frac{1}{3}z^2+\frac{1}{3}z^3)(\frac{1}{2}z+\frac{1}{2}z^2) = \frac{1}{6}z^2+\frac{1}{3}z^3+\frac{1}{3}z^4+\frac{1}{6}z^5$$$ , which indicates that after the second lock is opened, we are now at the second turn for the possiblity of $$$\frac{1}{6}$$$, the third for $$$\frac{1}{3}$$$ and etc. And you can calculate for the third lock for the same. After that, we've got the formula for the three locks. We can just sum it up for the answer. The final formula will be $$$\sum_{i=1}^{3}\prod_{j=1}^{i} \frac{1}{3-j+1}\sum_{k=1}^{3-j+1}z^k$$$. After doing the expanding, the coefficients will be the expect number(Three formula get for possiblities and sum it up we get the expects). And that since there are loops. When ever you get $$$z^n$$$ or higher ones you can just make them divide $$$z^n$$$. And that every polynomials you calculate will be just in n terms(for example, the formula for the second lock now turns into $$$\frac{1}{6}z^2+\frac{1}{3}+\frac{1}{3}z+\frac{1}{6}z^2 = \frac{1}{3}+\frac{1}{3}z+\frac{1}{3}z^2$$$ , which indicates that for the tree persons they have equal chance to open the second lock).

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

      Apologies for the necroposting

      But can you please explain why its always optimal to keep on opening the same lock after choosing a lock?

      Suppose we have

      L1 L2 L3 L4 L5 K1 K2 K3 K4 K5

      after we choose L5K4 pair and find it to be not valid, probability of L5K3 being valid is 1/4 but probability of L3K4 is also 1/4 but and does not use the same lock again!

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

        I mean, they are in the same position. If you take the same key, you can regard key as lock and vice versa, which doesn't affect the answer. So let's just say lock for convenient.

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

In div2 F, why should the second player apply a random strategy?

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

    I agree with you. I think it can be discussed by 2 cases:

    The chose don’t effect later persons: then for sure you can just choose the keys or just choose the locks for calculation.

    The chose effect later persons: it will be reasonable to randomly select for the objects remained when they are the same for the person choosing now so you do need to randomize the chose. However turns forms a loop, so until after the chose it is not possible for this person to choose, it should be randomized, for the other situations, since the chose will effect later persons including himself, he will choose the one(keys or the locks) which provides higher expectation.

    Thus, I think it is not reasonable to randomize the chose all the time.

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

      In the problem, it said: _"To open the toy box as soon as possible, every member chooses the key and the lock that maximize the probability of being a successful match. If there are multiple such pairs, a member will randomly choose one of such pairs with equal probability. "

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

        Then I can tell you why it will be randomized.It costs equal expected time whether to choose the keys or the locks ( just think that there are $$$l+k$$$ locks also ) so it will be the same possibility that to choose any object remaining ( which is ,$$$l-1$$$ locks and $$$l+k-1$$$ keys ) and trying to pair up it with the opposite one which is tried already.

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

I used priority_queue like Dijkstra to solve Div1B.

B1 Submission

B2 Submission

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

The solution for problem C does not look good, ig. Can you write a more beautiful and clearer code?

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

Can someone explain canteen(hard version)? I did not understand the editorial.

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

    What I did was fixating the amount of rounds (h) by binary search. Then for a specific h, I simulated how the rounds would affect $$$\Sigma a_i$$$ and then said it was posible to do in 'h' rounds if $$$k\geq\Sigma a_i$$$. To see how $$$\Sigma a_i$$$ would change I used a stack to access the closest non-zero $$$a_i$$$ and, if it was in a valid range ($$$i-j \lt h$$$), simulate how the ($$$j-i+1$$$)th round would change both $$$a_i$$$ and the $$$b_j$$$.

    My submission is 312846510.

    Hope this is of help -_-

»
17 месяцев назад, скрыть # |
Rev. 7  
Проголосовать: нравится +15 Проголосовать: не нравится

Really enjoyed solving problem 2089B1 and B2. Here is my $$$O(n)$$$ solution for B2.

My solution also considers a parenthesis sequence with $$$a[i]$$$ being the number of opening bracket sequences and $$$b[i]$$$ being the number of closing bracket sequences and doing a binary search to check if we can make all $$$a[i]$$$ zero with $$$ \lt = mx$$$ cyclic shifts. If some $$$(a[j],b[i])$$$ is taking more than $$$mx$$$ cycle shifts, we would need to reduce the current value of $$$a[i]$$$ to $$$0$$$ as we don't want to do this cycle shift. 313175241

For $$$O(n)$$$ solution we can just store for each $$$(a[j],b[i])$$$ that is being performed what is the reduction we need to perform so that this cyclic shift is not required which is just $$$min(a[j],b[i])$$$. Lastly we can iterate in reverse and take the prefix sums and check if we have sufficient value of $$$k$$$ in order to not perform the $$$ith$$$ cyclic shift. 313175736

Apologies for my bad English. Let me know if some part is not clear.

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

great contest

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

solution for d (simple permutation): https://youtu.be/LthXrsjfilI?si=csvXnGlNQkC2MzO5

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

In the editorial of 2089B2,I dont understand why "If minj=i+1i+xcj>ci , then we should apply minj=i+1i+xcj−ci changes to ai+1".Can someone explain it for me?

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

    To answer your question/ explain more thoroughly on B2's solution in general:

    For each $$$i$$$, we want to look at the $$$c_j$$$ values for the next $$$x$$$ elements(that is, $$$j = i + 1, i + 2, ... i + x$$$) in front of $$$i$$$.

    If there is no $$$c_j$$$ with value smaller or equal to $$$c_i$$$(which we will call the qualifying condition for the left brackets/$$$a_i$$$ values at position $$$i$$$ to have paired with all necessary right brackets/$$$b[i]$$$ values by the time they are at position $$$j$$$), these $$$c_j$$$ values must all be greater than $$$c_i$$$. To meet this qualifying condition we 'edit' some elements in the array to make it possible. Now we just have to determine the best possible edit.

    We cannot decrement $$$a_0...a_i$$$, since this would change both $$$c_i$$$ and $$$c_j$$$ such that their relative value stays the same. So we must decrement some $$$a$$$ element in the range $$$a_{i + 1}...a_{n - 1}$$$. Remember we want to reach the qualifying condition using the minimum moves, yet make these moves as optimal as possible. Note it is optimal to decrement element $$$a_{i + 1}$$$ since this would decrease the values for a maximum number of $$$c$$$ elements(that is, $$$c_{i + 1}...c_{n}$$$), making it more likely for the next(decreasing) $$$i$$$ indicies to find a $$$c_j$$$ above it that is smaller.

    Hope this clarifies!

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

Treasure Hunt needs a correction in the question instead of a.5 it should be a .And it test case 2 at the third token for the accepted answer gives YES but the expected output according to the test case is NO . I don't know how magically it giving an output of NO for the program which gives YES for the same input and accepting it

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

    If it was a, the answer would be "NO" in the first sample, because the first guy reaches depth 4 earlier. No clue what you're saying about testcase 2, your solution outputs YES, the expected answer is NO, so you have wrong answer on test 2.

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

I think tests in B1/E1 are not enough to check it for tl, because my solution works O(n*n), I even have a test for it but somehow it passes. Would you check it, maybe I understood something wrong. Thank you in advance)

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

I solved div2C using priority queue. Here's my code: 347603855. I consider it to be O(n) time, but it uses a lot of memory, how could i prevent that?

»
7 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится +8 Проголосовать: не нравится

Deleted