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

Автор 300iq, история, 6 лет назад, По-английски
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Разбор задач Grakn Forces 2020
  • Проголосовать: нравится
  • +129
  • Проголосовать: не нравится

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

Rip FSTs on B

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

So tourist as you now have 500 Euros, please give me a party!

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

Test 9 on problem B... It just destroyed everyone.

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

    well, not everyone...correct solutions have passed.

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

    Well, it do seems that many people wrote the correct solution, but failed because of some details... At least I do.

    The issue is that nothing shows the special detail on pretests.>_>

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

    I didn't understand the editorial of problem D. Please someone help me to understand it.

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

      i is for ith robber j is for jth search light. x+y is the solution of our problem . Here in this editorial author is calculating the value of y for diffrent value of x. Let's say a[i] , b[i] is the position of one robber . As x , y is the answer so every robber position will increase by x and y. To escape from c[j] ,d[j] searchlight , either of condition must be true (a[i]+x)>c[j] , (b[i]+y>d[j])

      for x >(c[j]-a[i]) we don't need to calculate y as one condition is already satisfied. for x from 0 to (c[j]-a[i]-1) we need to calculate y and its minimum value will be d[j]-b[i] .

      I hope you can think further .

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

        But we will still need to iterate over all possible values of x for every robber and search light pair, that makes it O(C*m*n) , how to optimise this.

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

          I think this is the part where both you and I got lost on the editorial: So we have n*m queries of max= on prefix. We can do it using suffix maximums.

          It just starts to make sense to me. For any search light and robber pair, let's denote dx = c[j] — a[i] and dy = d[j] — b[i]. if dx >= 0, it means that for all right moves ranging from 0 to dx, we must move robber up by dy + 1. Instead of doing updates on all x in range[0, dx], we just set r[dx]] to max(r[dx], dy + 1), representing this prefix range must have how many up moves associated with them.

          After processing all n * m pairs, we then do a linear scan from right to left,(this is the suffix maximum the editorial mentioned) and update on each possible right move x, the least up moves we must have at that x. This must be done from right to left since r[x] of bigger index has an impact on smaller index, but not vice versa.

          I guess this is kinda similar with the common technique used in counting number frequencies for a given set of intervals [l, r], we would add 1 at index l then subtract 1 at index r + 1, then do a prefix sum computation from left to right.

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

What the hell with the problem F? why do you assume that we can use 2^(k+1) elements, which is strictly bigger than n in most cases? We only have n elements in the array a.

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

It was a Div 1.5 actually.!

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

A bit different idea for C, so that you can do it similar to solution 2, but avoiding complicated part with the last segment being reached at different moments from different sides... Or maybe just a different way to approach the same idea.

Generate events "one of the cars reaches some flag" and sort them by time. Now you can say that every time the event happens total speed of two cars increases by 1, so you can proceed events one by one while maintaining current distance between the cars. Once you reach the point at which next event results in negative distance, you know that the cars met between previous and this event, and you know that their speed during that time period was constant, so finding the exact answer is easy. Possible implementation in 94309676.

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

what does this bit in problem A mean thou ? pi≠p(i mod n)+1.

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

Seems like problem setters were not very cooperative with the contestants while giving sample test case for Problem D. I agree I missed very simple case when all robbers are in safe position. But I guess it would have been very helpful if we had a case in sample test case which has answer = 0.

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

How to write the output-checker of F?

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

What is the proof for problem B?

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

.....

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

Um_nik can you please explain your solution for F as you did some complex merging for even and odd length intervals.

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

    Yeah, I did some hard bullshit instead of trivial solution, do you really want to hear it? Why?

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

      Yes I want to know as I was trying for the same and finally resigned after thinking that it was not possible that way.

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

        ok

        If you can solve $$$n$$$, you can solve $$$2n$$$: do solution for two halves and then merge equal sets in $$$n$$$ operations.

        If you can solve $$$n$$$, you can solve $$$n+1$$$: do solution for $$$n$$$, now you have two sets A and B of total size $$$n$$$ and one more set C of size 1. Let's assume that A is larger (or the same size) than B. We'll try to double C by taking parts of A or B and getting rid of B completely. Since we will be doubling C its size will go through powers of 2, and the same is true about the parts we will be taking from A or B. That gives an idea that we have to look at the binary representation of B and take the part from B when we need it. What to do when we don't need it? Let's take a part from A. It's easy to see that the total size of everything we'll take from A is less than even the largest part we'll take from B, so A cannot run out before we use B completely. So after that we'll have only A and C. We'll use no more than $$$n$$$ operations to do it.

        So, the total number of operations is bounded by $$$T(n) \le 2 T(\lfloor n / 2 \rfloor) + 3n / 2$$$ which should result in $$$T(n) \le 3/2 n \log_{2} n$$$.

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

Can anybody elaborate their binary search solution on problem C , i am not able to understand through editorial

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

    For problem C, I did binary search on time variable. For a given time, I calculate the total distance travelled by the person that starts from 0 and I calculate the total distance travelled by person that starts from the end and check whether they cross each other.

    Submission: https://mirror.codeforces.com/contest/1408/submission/94324318

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

      Karan123 Great code. Can you please explain what does the variable eps means? I have never used binary search on double/float values. Can you please explain why the while condition is end-start > eps ?

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

        The invariant I have used in the problem is that start variable always points to the time in which it is not possible for the two cars to cross each other and end points to the time for which the two drivers will always cross. start will always begin from 0 since at t=0 they cannot cross and in the worst case when there are no flags, the drivers will require atleast $$$\frac{10^9}{2}$$$ time (I have choosen $$$1e9$$$) time to cross. Now, after I calculate the middle value, I check if the drivers can cross each other. If they cross then we can do end=mid and if they cannot cross we keep start=mid. It is always true that start always points at time at which the drivers can not cross and end always points at the time at which they cross. In the while loop, I decrease end as much as I can and I increase start as much as I can. If end-start<=eps, then I have the lowest end I can achieve which is the least time required. Why did I choose eps as 1e-7: In the question, they have mentioned that they need precision of answers to be 1e-6. eps variable is used to handle that. Normally in integer questions we take jumps of value 1 i.e. we move from one integer to another so we keep eps=1 in integer questions, but in double values we take jumps of eps value and eps value is less than the required precision.

        I learned this concept in Binary Search of EDU Section. I would suggest you to do that.

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

    For a particular value of t, find the position of both the cars(x1 and x2). If x1 < x2, that means the cars have not yet crossed, so we try for a greater value of t. If x1 > x2, then the cars have already crossed each other. So we try for lesser value of t.

    We keep trying like this till the difference between the positions of cars reduces to less than ϵ.

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

    I feel like it is easier to not do binary search but instead find which car reaches a flag first and update the velocities and positions. Keep doing this until the two cars have no flags in between them and then find the remaining time. This is my solution — https://mirror.codeforces.com/contest/1408/submission/94324831 If you still aren't clear send me a private message

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

I found Maximum Spanning Tree in problem E, isn't there a typo in the editorial?

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

Is it so difficult to create nice easy problems? In my opinion D, E, F were nice and A, B, C were ugly.

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

What questions to solve so to easily solve questions like B in this contest?

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

Why ternary search doesn't work in problem D? submission

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

    Looks like you are ternary searching on the x shift. Ternary search doesn't work because the function can have multiple local minima. Sample case 2 gives 7 8 [4] 5 6 7 8 [7] 8 9 10 11 12 13 14 which has 2 minimums and ternary search can converge to any of them not necessarily the global minimum.

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

pretest poor

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
»
6 лет назад, скрыть # |
Rev. 7  
Проголосовать: нравится -107 Проголосовать: не нравится

.......

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

Can someone explain the solution of problem D . couldn't understand what is done in editorial.

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

No codes?

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

i don't understand why not putting testcase 9 for B.

1) trapping someone is not nice.

2) in some worst case scenario, someone can get free 1000 point by spamming "1 4 4 1 1 1 1" which is ridiculous.

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

I think the TL on problem D was quite strict. I did an overkill using segment tree but still I feel that N*M*log(C) + C*log(C) should have passed the time limit

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

can anyone share problem c binary search solution

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

Loved the contest, though will lose a lot rating

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

ok

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

Statement of problem E had a HUGE hint (description of the cycle tells us we can make our graph bipartite).

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

    Sorry, if this sounds stupid, but could you please describe this a bit please. I completely understand the editorial, like, how does making the virtual verticies for each set, and making a bi-partite graph out of it is helping.

    I also get, to why we need to find the Max Spanning Tree.

    Yet, I fail to realize, what could have hinted me, to use all of this. Or what prompts us to do create the virtual vertexes for each set, and making the bi-partite graph out of it.

    Thanks in advance.

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

      Well, there is not much else I can say. $$$i_1 \rightarrow e_1 \rightarrow i_2 \rightarrow e_2 \rightarrow ... i_1$$$. Now we want to make all the colors of the edges different. It's the same as replacing $$$e$$$ with $$$color_e$$$. So like you can imagine one more vertex in the middle of the edge which is the same vertex for the same color.

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

        Right, I get it. That could be used, to hint for creating the virtual vertices, and then, we can see, vertices from set i connect to vertices from set e. This I guess can hint the making of bi-partite graph ( as we have two sets, and edges are only such that they connect vertices from one set to another ).

        Great. Thanks !

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

Can someone explain the editorial of the problem D? Or any other way of solving it !!

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

Why does an nlogn approach gives TLE in D. I tried using a multiset to store the suffixes after sorting and then kept on erasing the values while traversing. This is my submission : https://mirror.codeforces.com/contest/1408/submission/94342487. Any help would be appreciated.

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

How to be familar with FWHT enough?

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

Beautiful E

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

Quite late, but here's my fun screencast with commentaries + solutions + playing chesss during contest :)

Link.

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

in problem 'C' I get "TLE" for my binary search solution any hints! https://mirror.codeforces.com/contest/1408/submission/94357957

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

During the contest I sent this code https://mirror.codeforces.com/contest/1408/submission/94329698 And get WA due to precision

And right now I sent this one, getting AC. https://mirror.codeforces.com/contest/1408/submission/94361563

The only difference is: in the first one I use integers in some operations that I know that could be made with integers and later I cast to double, and in the last one I just change all the integer numbers to double. My question is: Is better work only with just one data type or What could be the issue? I thought that would be better if I managed some operations first with integers.

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

About problem G: Could anyone explain how the polynomial multiplication in the merge operation end up being O(N^2) overall?

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

    The transition ends up looking something like $$$dp_{\text{merge}(A, B)}[i + j]$$$ += $$$dp_A[i] \cdot dp_B[j]$$$ for every two components $$$A$$$ and $$$B$$$ that we merge, for all $$$1 \le i \le size(A)$$$ and $$$1 \le j \le size(B)$$$. That is, we perform $$$O(size(A) \cdot size(B))$$$ operations, and we want to estimate the sum of this over all merges.

    To analyze the total complexity imagine that whenever you merge two components $$$A$$$ and $$$B$$$, you write down the pairs $$$(a, b)$$$ for $$$a \in A$$$ and $$$b \in B$$$. Then the number of pairs you write is equal to the number of operations you perform in a particular merging step. But notice that each pair $$$(u, v)$$$ will be written at most once. This is because once it is written for the first time the vertices $$$u$$$ and $$$v$$$ will lie on the same component on all future steps. There are $$$O(n^2)$$$ possible pairs of vertices, each written at most once, so there's also $$$O(n^2)$$$ total operations.

    Edit: Sorry, I used slightly different notation than the editorial. Here $$$dp_C[sz]$$$ denotes the number of ways to split component $$$C$$$ into $$$sz$$$ sets.

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

In problem B for test case 4 2 1 2 3 4 the answer should be 2 as 1 2 1 2 0 0 2 2 but in everyones code it is the output 3

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

When I read the solution for F,I just want to laught at myself....Nice problems!Thanks.

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

Anyone with binary search solution for problem C ? Please share..

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

This contest is very difficult,I think(

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

And don't remember that the real answer is the smaller value of $$$\frac{z}{2}$$$ and your matching size.

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

Not able to understand the solution of Problem D, someone please help

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

Please can someone explain the solution of problem D?

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

Finally got the right color!

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

can someone explain the editorial of B?

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

Guys like me who just struck till problem D thinks that the problems are really nice . Now after reading the statements of problems E, F and G found them really really nice . It's truly said , " beauty lies in the eyes of beholder " and Pure Mathematics is the most beautiful thing . I will try to upsolve these nice problems now . I think i will have a great day now with these beautiful problems :) Thanks 300iq & isaf27

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

Why does the following approach not working:-

Basically increasing the relative speed(starting with 2) every time a flag is encountered. The flags are processed from left to right ( i & j in the code) and whichever flag is closer to the current position of the car is chosen to update the relative speed.

my code

solution for the pretest (is close but not right):

3.000000
3.666667
2.042857
324619672.333333
53.700000
»
6 лет назад, скрыть # |
Rev. 4  
Проголосовать: нравится 0 Проголосовать: не нравится

Can any one tell me why my approach giving wrong answer for Problem F. Link To MyCode

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

In problem H, can somebody explain in more detail how to solve maximum matching problem, where a node on the left can be matched with either a prefix or a suffix on the right?

Observation 6 of the editorial tells us a method, but it seems to ignore the existence of $$$r$$$ completely. What happens when for a given $$$x$$$ you don't have such $$$(l, r)$$$ with $$$l \leq x$$$? Maybe I missed some key statement in the editorial, in which case I would appreciate if you could point me to that.

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

    It does not ignore $$$r$$$, as I choose the pair with the smallest $$$r$$$. I forgot to write that after that on $$$r$$$'s of the remaining tuples we have to solve the problem "guy can be matched with a suffix, find the maximum matching".

    About your other question, $$$x$$$ corresponds to the position in the left part. If you can't find a pair for the fixed $$$x$$$, just ignore it.

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

      Let me see if I got it right, so what you are describing is something like:

      1. For each $$$x$$$ decreasingly, try to match it with the pair $$$(l, r)$$$ with minimum $$$r$$$ such that $$$l \geq x$$$ and $$$r$$$ is as small as possible.
      2. For each of the unmatched $$$x$$$ decreasingly, try to match it with some unmatched pair $$$(l, r)$$$ where $$$r \geq n - x + 1$$$ and $$$r$$$ is as small as possible.

      This seems very asymmetrical to me, any small hints why it works?

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

        No-no-no. That's not what I am trying to say.

        Alright, so $$$1$$$ is right.

        After that, you have some unmatched pairs $$$(l, r)$$$, and $$$l$$$ for them does not matter anymore. So your goal is to find the largest matching for $$$r_1, r_2, \ldots, r_k$$$. Where $$$r_i$$$ denotes the number of elements on the suffix that $$$i$$$-th element can be matched with, you can do it in any way you prefer.

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

PD. why ans need add x ?

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

CAN ANYONE EXPLAIN ME C PROBLEM IN SIMPLE LANGUAGE. I JUST USED BRUTE FORCE APPROACH CALCULATE DISTANCE TRAVELLED AT PARTICULAR SPEED (MEANS I TOOK TWO POINTER ONE FRONT OTHER BACK AND FOR TRAVELING TO 1 IT TOOK 1 SECOND FOR FIRST AND TO TRAVEL L-1 IT TOOK 1 SECOND FOR BACK AND I JUST INCREASE THE SPEED AT FRONT AND/OR BACK IF 1 AND/OR L-1 COORDINATE ARE PRESENT IS FLAG ARRAY AND JUST REPEAT THIS PROCESS ). INCREASE THE SPEED ACCORDINGLY AND BREAKED THROUGH THE LOOP AS THE FRONT >=BACK. IS THIS APPROACH WA.

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

Is there any detail editorial for problem I using fwt

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

Can someone explain the solution to problem D ? By now I have understood the following part of the editorial.

Let's define as x our move to the right and as y our move to the up. For all pairs (i,j) of (robber, searchlight) at least one of this should be true: x+ai>cj, y+bi>dj. So if x≤cj−ai then y≥dj−bi+1. Let's make an array r of length C=1e6 and write on each position of x the minimum value of y.

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

I'm highly dissatisfied with your "It's easy to prove" in problem B editorial. If it was so easy, then why did you shit with its preparation (and your vaunty testers that sometimes write "I'm a tester, so provide me with contribution" and collect hundreds of upvotes)? I deem it necessary for you to write a comprehensive analysis for this problem as a lesson to yourself.

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

But otherwise the round was extremely qualitative, ideaful, and beautiful. Just visible are the huge efforts that you contributed to the round. Thank you for doing so!

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

Can someone explain this line from the editorial of problem E , We will connect vertex i from the left side with all elements of Ai. That implies that there will be m*n edges in this graph . How to calculate MST on this graph since the number of edges are huge??

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

very elegant solution for F! Even G was really beautiful problem. Thanks!!

»
6 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится
It can be proven, that the graph, which we create using our sets don't have rainbow cycles if and only if our bipartite graph don't have cycles.

Then prove it in the editorial itself or provide link for the same. Can anybody tell me how to prove what's written in the editorial of Problem E?

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

can anyone provide me the binary search solution of problem D?

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

Can "maxflow" works in H? I have one solution based on "HMT". code

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

    It seems that your solution strikes a lot of similarity with tourist ’s solution Link, which I’m struggling to understand for a couple of days now. Could you please check if that’s true?

    Can you give us more details about this ’HMT’ thing? (EDIT: never mind, I guess it means Hall Marriage Theorem)

    The best thing I got is that your solutions seems to solve the hitting set problem as the dual for the bin packing problem. Also, maybe it’s related to the matroid intersection approach briefly mentioned in the editorial, which I’m not familiar with.

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

      HMT must stand for Hall's Marriage Theorem, which my solution is based upon indeed.

      1. Binary search on the answer, $$$k$$$.
      2. We are joining the $$$i$$$-th zero from the left and the $$$(k-1-i)$$$-th zero from the right into a pair for each $$$i$$$ (0-based).
      3. We want to check if a perfect matching exists from these $$$k$$$ segments into distinct numbers inside them.
      4. Let's use Hall's Marriage Theorem. Since all segments have a common point, it's enough to check consecutive sets of segments instead of arbitrary subsets.
      5. A perfect matching exists iff for any $$$i$$$ and $$$j$$$, there are at least $$$k - i - j$$$ distinct numbers between the $$$i$$$-th zero from the left and the $$$j$$$-th zero from the right.
      6. Finally, get rid of binary search. The answer is the minimum of $$$\lfloor z / 2 \rfloor$$$ and $$$f(l, r)$$$ over all $$$0 \le l \le r \lt n$$$, where $$$f(l, r)$$$ is the number of distinct numbers inside $$$[l; r]$$$ plus the number of zeros outside of $$$[l; r]$$$.
»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Problem E. Can someone please explain the intuition behind the below claim/statement? "It can be proven, that the graph, which we create using our sets don't have rainbow cycles if and only if our bipartite graph don't have cycles"

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

A visual attempt at deciphering problem D (nice problem!) :

Reference Code

(Credit: Thanks to SecondThread's excellent youtube editorial)

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

Is problem D known or something?
It was very hard to even understand the tutorial, but it seemed a lot of people solved it. Once I got the point, it seemed intuitive, but there are still difficult small details that you have to do. For example, the fact that you use exactly the distance to the border of a square, and not +1 (not escape entirely), only so at the end, at the final update, you do +1. Another hard small detail is updating r[x] = max(r[x],r[x+1]) (max prefix), which is not an easy detail.

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

Anyone willing to elaborate on G?

I'm probably missing something. Why do we keep DP and traverse edges in ascending order? I believe it is possible that edges forming connections inside of groups aren't necessarily prefix of edges sorted in ascending order. I can't understand editorial at all..

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

I might be wrong, but I just checked QAQAutoMaton's profile, and I found no submission for 1408I.

If you have a Nlog^2+log^6 code (or perhaps know someone who does), please reply to this with a link to the submission. It would be much appreciated.

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

Editorial for Problem D:

Here is a visual diagram for test case 2:

Click for image

For this problem, here is a good explanation for the same — link, I have just used an example to explain the same :)

First of all, for each Robber -

  • we need to find the max possible steps we need to make to escape all the searchlights.
  • If we can make all robbers move horizontally, such that the min x-coordinate of robbers is > max x-coordinate of search lights, or vertically min y-coordinate of robbers is > max y-coordinate of search lights, all robbers can escape.

So instead of focussing on getting the min steps, we break our problem into two axes, and concentrate on X and Y axis separately.

Let i denote the ith Robber and j denote jth Searchlight. Here a[i], b[i] coordinates of ith Robber, and c[j], d[j] the coordinates of the jth Searchlight.

For each Robber

  • we want to find dx = c[j] - a[i], dy = d[j] - b[i] and if dx>=0 then we can say the searchlight is ahead of robber. If not, we know that the robber is ahead of searchlight, and we don't need to care about ith Robber.
  • If dx>=0 we know for sure, if we move ith Robber by delta steps, 0 <= delta <= dx rightwards, then we still need to move dy + 1 to escape the jth searchlight. So we can create an events array events, which would store the max amount of vertical steps required by all robbers, such that all the robbers can escape at point dx.
Constructing the events array

So finally, we have, for each dx, max amount of steps required to free all the robbers. Note the value of events[dx] denotes the max possible steps required vertically, so that all robbers can escape all the searchlights.

We dont update all the values from [0, dx] with the vertical steps required, because else we would TLE, as TC would be — O(N * M * dx). Use this resource to learn more about line-sweeps.

Now we can try all the horizontal steps before taking the events[dx] number of vertical steps. We need to take care of the max vertical steps, from right to left, because once we encounter max vertical steps in the test case, the max vertical steps occurs at dx = 6, vertical step = 2, so we cannot move less than that. So a running maximum from right to left is also required, while we take the minimum (dx + vertical steps)

Taking running maximum from right to left

Here is my submission for reference — https://mirror.codeforces.com/contest/1408/submission/115845270