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.

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.

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.

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

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.

You start at (0,0) so if you end up at some (dx,dy) it means you have gone atleast dx in the x axis in the same direction and dy in y axis in the same direction. so it means if you come back dx and dy steps in the respetive directions you will be back at (0,0). For example consider this case 6 LLRRRR

you are at 0,0 initially now you go l l so you are at (-2,0), then you go r r r r so you are at (2,0) which is 2 places right of the place you need to be(ie (0,0)) so you subtract that from 6 and you get 4 which is the answer. Hope this helps