В качестве эксперимента мы решили сделать раунд Educational Codeforces Round 33 рейтинговым для Div. 2. ×

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

Автор BledDest, история, 12 дней назад, По-русски,
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Разбор задач Educational Codeforces Round 32
 
 
 
 
  • Проголосовать: нравится  
  • +66
  • Проголосовать: не нравится  

»
12 дней назад, # |
Rev. 2   Проголосовать: нравится +91 Проголосовать: не нравится

I liked this round. Generally, the idea of educational rounds is very good. That one in particular expanded my horizons. Usually, when you learn MST, you think: "Why should I bother with Prim's or Boruvka's algo? Just learn Kruskal and forget about the rest". Task G reminds us that every algorithm is important and can have its own unique application.

  • »
    »
    12 дней назад, # ^ |
      Проголосовать: нравится +53 Проголосовать: не нравится

    Before this round, I didn't even know about the existence of Boruvka's algorithm.

    • »
      »
      »
      11 дней назад, # ^ |
      Rev. 2   Проголосовать: нравится +23 Проголосовать: не нравится

      Neither did I.

      Educational Rounds always teach us about some cool new algorithm or an application of an old algorithm that is not quite popular. :-)

  • »
    »
    9 дней назад, # ^ |
    Rev. 2   Проголосовать: нравится +29 Проголосовать: не нравится

    FWIW, you can solve this by starting with Kruskal's algorithm too. If you only look at the highest bit at b = 29, and split your vertex set into two halves V0 and V1 (one with all vertices where bit b is turned on, the other all the vertices where this bit is turned off). It follows that internal edges in either V0 or V1 will have bit b turned off, but edges between the two components will have this bit turned on. Thus, if you were to run Kruskal's algorithm you would first enumerate all internal edges in V0 and V1 before considering edges between the two components. It follows that Kruskal's algorithm would first connect all of V0 into a single tree (V1 respectively), and then find a single connecting edge between the two components.

    This gives you a simple recursive algorithm: Split on the highest order bit b, solve these two halves recursively (only considering bits  < b), and then find the weight of the single connecting edge, i.e. given two sequences of values, find the pair of values with minimal exclusive-or. This last problem can be solved using a very similar recursion.

    Code: 32170476

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

Hey guys! Here are some of my thoughts on the meet-in-the-middle techniques on problem E: http://robezhang.blogspot.com/2017/11/meet-in-middle-technique-on-educational.html Feel free to ask questions and give suggestions!

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

Why don't you put your implemented codes with the tutorial?I think it will be helpful for many of us :)

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

For problem C can someone explain this part:

" Write down lengths of segments between two consecutive occurrences of this character, from the first occurrence to the start of the string and from the last to the end of the string."

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

    Let k be the maximal length such that there exists segment of length k that doesn't include character c. You can take all the occurrences of character c and check where this segment can fit. Thus maximal distance between those occurrences and ends of the string will get you maximal k.

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

how the bitmask solution look like for Probelm E?

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

    i think the bitmask is for easy iteration over all possible subsets. Suppose there are n elements then iterate over 0 to 2^n for all possible subset generation.

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

Look at my codes for the problem F. I wrote a solution using an algorithm Boruvki but unfortunately it got TLE. Even though my realization is not good as author might have expected to see, I think 2 seconds for the problem which has complexity of is (very) tight

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

    Try first sorting numbers. I have no idea why it works, but I also had time limit with same solution and sorting the numbers mad code at least 2x faster.

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

Thank you for good problems. Seems, like the problem F was appeared at some opencup contest before, but without the matrix a, which, actually doesn't make the intended solution harder. I have some suggestion: what about set the modulo something like 998244353 in future? It make sense, because it allows to write solution with FFT.

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

Doesn't the Boruvka's algorithm work for graphs with distinct edge weights only? In the case of problem G, how is that guaranteed?

  • »
    »
    9 дней назад, # ^ |
      Проголосовать: нравится +12 Проголосовать: не нравится

    It is not guaranteed, hence the warning.

    but we should be careful to avoid adding edges that form cycles in MST

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

      Can you please elaborate how is the repetition avoided ??

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

        The problem is with duplicates. Instead of dealing with just weights of edges, consider the pair (w, i) for each edge, where w is its weight and i is the edge index. Now no two pairs are same as each edge has a different index and you can run Boruvka's algorithm as usual.

        Code

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

Can anybody elaborate D? for m, 0<=m<=k, pi != i. isn't this a derangement? How can there be nCm ways to do this?

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

If I understand correctly, the editorial claims that the answer for B is always n — dx — dy. Can someone prove it mathematically? How about an intuitive proof?

Was just trying to figure out how I can come up with such ideas myself in the future. This sounds like a genius idea to me but I am not sure why it works.