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

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

2224A - Zhily and Array Operating

Tutorial
Implementation

2224B - Zhily and Mex and Max

Tutorial
Implementation

2224C - Zhily and Bracket Swapping

Tutorial
Implementation

2224D - Zhily and Barknights

Tutorial
Implementation

2223C - Zhily and Signpost

Tutorial
Implementation

2223D - Zhily and Cycle

Tutorial
Implementation

2223E - Zhily and Permutation

Tutorial
Implementation

2223F - Zhily and Colorful Strings

Tutorial
Implementation
  • Проголосовать: нравится
  • +26
  • Проголосовать: не нравится

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

Sorry, the implementation might be unauthorized, we're solving it...

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

https://codeforces.me/contest/2224/submission/373788886

The java implementation for 2224D solution 2 got TLE with Fenwick tree, but it passed with merge sort. Wondering why...

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

The solution for Problem $$$\textbf{Div2}$$$ $$$C$$$ is not clear!!

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

    It may be more intuitive to apply the greedy algorithm to verify whether the value of the number of left parentheses minus the number of right parentheses in the two strings is valid.373672904.Hope it will help.

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

      Hi, thanks for the implementation. It was really easy to understand. I dont understand, why does this greedy work? If you could just tell me the intuition behind it, that would be a great help. Thanks

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

        Because when the number of right brackets in a prefix exceeds that of left brackets (the value becomes negative), the bracket string is definitely invalid. Therefore, we traverse each position i from left to right. If the brackets at a certain position differ, we greedily place the left bracket at the position with a smaller value (the smaller difference between the count of left and right brackets). This approach is always optimal, as we keep raising the minimum value to prevent right brackets from outnumbering left ones. If this cannot be achieved, the string is bound to be invalid, just as I mentioned earlier.And if everytime the value is valid,just check if it is 0 in the end.Hope it help!

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

    We are changing a new version of it. Hope it will help.

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

I created video editorial for D. Zhily and Barknights

I created video editorial for E. Zhily and Signpost.

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

can someone pls point out the mistake in this? (the function full of comments is taken from gfg)

»
6 месяцев назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится
Specifically, we have Mv=lcm(Mu,du). Then m≡Ru (mod Mu) implies m≡kMu+Ru (mod Mv), k∈[0,gcd(Mu,du)−1]. By enumerating all k and computing the corresponding r, we can obtain the congruence equation for su,r. If some r is not obtained, then the congruence equation corresponding to su,r has no solution.

Should not $$$k$$$ range over $$$[0, \frac{d_u}{\gcd(M_u, d_u)} - 1] $$$ ?

EDIT: I got it. $$$k \in [0, \frac{d_u}{\gcd(M_u, d_u)} - 1]$$$ if the modulus is $$$d_u$$$

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

I'm new here. Can somebody tell me why the source in the implementation shows "N/A"? Is my viewing permission sufficient?

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

can someone please help me figure out why my submission resulted in rte for preblem C? i used a binary searching like technique on centroid

https://ideone.com/OYXng2

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

slowEditorialForces

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

Is problem (div2)D solvable in Python without getting TLE?

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

Solution of problem B can be implemented easily by using mathematics if we observe pattern in the optimal answer when $$$max(a_1, a_2, ..., a_n) \geq mex(a_1, a_2, ..., a_n)$$$ and when it's not.

Check out this submission

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

The fastest task analysis this year!!!

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

Anyone else tried solving 2E/1C using binary search?

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

Hi, I am not able to see the code in the submission given under implementation. Does it have anything to do with this being my first contest? How can I fix this? Appreciate anyone's help.

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

Also, can someone tell me where I went wrong in my solution for Problem B, Div 2?

Edit: Got it, LL conversion error.

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

I think Div2 problem C is much simpler than Div2 B.

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

weird contest

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

C is easier than B...

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

For problem div2 E/div1 C, i suggest an alternative solution using binary search on centroid decomposition tree. Though i will not go much into explaining it, the way it works is check whether a node u in the centroid tree is reachable from 1, if it is then the answer must lies inside the subtree of u, then compute the next normally. If not then it can be seen that the answer is not inside the subtree of u, so we find go to the parent of the node u in the original tree and its centroid, note that we always move to a centroid with higher depths in the centroid decomposition tree.

I wonder if this technique caa be extended even more though, as centroid decomposition is almost like DNC on tree, so maybe we can extend it even further?

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

in question A there is written we have to find number of positive number in array, is 0 not a positive number??

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

any help, my submission submission got different wrong answers for different c++ versions , i.e : in c++23 it got WA on test2 case 9 , in c++17 got WA test2 case 6 , in c++20 got WA test2 case 11, what's the issue despite i submit the SAME code && the "failed" testcases as codeforces saif got the correct output Locally but different output on codeforces

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

Can anybody explain whats the proof of greedy in div2 C?Like why is it that balancing the difference in A & B is optimal?What if A has more open brackets so we can have its diff less than B and give more open brackets to B before while ensuring that no one has diff<0 at any point?I have the intution on why greedy is working but i just cant prove it

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

i had a different solution to 2224C (zhily and bracket swapping). the basic idea is to alternate between setting $$$a_i$$$ as '(' and $$$b_i$$$ as '(' at all entries $$$i$$$ such that $$$a_i \neq b_i$$$. then, just check if the resultant strings are valid. it is easy to prove this is correct by noticing the max discrepancy in open and closed parentheses this creates is one.

for an example, if indices 4, 6, 9, and 10 differ between strings $$$a$$$ and $$$b$$$, set $$$a_4$$$ as '(', $$$a_6$$$ as ')', $$$a_9$$$ as '(' and $$$a_10$$$ as ')'. then, check if $$$a$$$ and $$$b$$$ are valid.

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

    weird solution honestly, it seems impossible to proof the choice of starting with ( , ) not with ) , ( for setting x[i] and y[i]. The same thing for swapping all different pairs , how can you proof that swaping all pairs works ?

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

in $$$D$$$ let $$$d = a * b$$$ then answer is just $$$\frac{inv(d) - n * (inv(a) + inv(b))}{n (n - 1)}$$$ where $$$inv$$$ is the number of inversions.

$$$\; \; a * b = [a_0 \times b_0, ..., a_0 \times b_{n- 1}, a_1 \times b_0, ... ]$$$

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

Div 1F: What exactly is multivariate Lagrange inversion and where can I find a proof (in English)?

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

Has anyone done 2224D using binary search in Java, I would like to see your solution, I am getting TLE with the same code in java but it runs in cpp.

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

Overdid the first problem by lazy seg tree LOL !!!

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

why is Div2 D not accepting O(N^2 * log(N)) solution? Is my solution too expensive because of constant factor? Did anyone solve this using pb_ds ?

My submission: 382022983

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

From D1E editorial,

In fact, during the problem preparation, this conclusion is naturally obtained from a more complex but powerful structure; for simplicity, we now consider the direct proof above.

What's this structure?