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

Автор Qingyu, история, 5 лет назад, По-английски

Let's discuss problems here.

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

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

Is there an official editorial? If not, then how to solve J?

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

How to solve problem D? MO algorithms gives TLE. I have an idea with Merge Sort Tree(as segment tree,but we store elements) . Will it pass ?

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

    We solved D with Mo's Algorithm in under 2s. The idea is to have purely $$$O(Q \sqrt N)$$$ complexity (no log factor). You can do that with linked lists and undo (change inserions to erase and adapt Mo's Algo accordingly).

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

    We used Mo algorithm with linked list over sorted segment. Deletion from linked list is $$$\mathcal{O}(1)$$$ and you use rollbacks to insert elements. To make this work with Mo algorithm sort queries by $$$(r/B, l, r)$$$. Then for each block you have $$$l \in [0, r)$$$ and $$$r \in [B * block, (B+1)*block)$$$, so insert all items from range $$$[0, (B+1)*block)$$$ into linked list, then to handle each query in sorted order you:

    1. Permanently remove some elements from left side
    2. Temporarily remove some elements from right side
    3. Retrieve answer
    4. Rollback all deletions from right side
»
5 лет назад, скрыть # |
 
Проголосовать: нравится +39 Проголосовать: не нравится

How to solve problems G from Div1 and M from Div2 ? Our team thought may be random will work for M.

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

    My Solution for Div.2 M: Let's shuffle the given permutation. The interactor is not adaptive, so we can assume that each location has an equal probability of containing a treasure, assuming it is $$$p$$$. Suppose we examine the first 20 locations in turn, then the probability that the first 20 positions do not contain any treasure is $$$(1-p)^{20}$$$. If this happens, then we can assume that $$$p$$$ is sufficiently small, so that among the remaining positions, we can assume that the probability of picking any two positions, both of which contain the treasure is small ($$$p^2$$$). Then, we perform about 20 more queries, choosing 2 adjacent positions for each queries. There is a $$$p^2$$$ probability of missing the answer. But since $$$p$$$ is small enough, $$$p^2$$$ is also small enough. If we still do not find an answer, then we consider the distribution of the treasure to be more sparse, and continue to increase the number of locations per query. The limit on the number of queries does not appear to be strict, and can be passed by taking a random reasonable set of strategies. Code

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

Is there any div.2 editorial available?

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

    Problem A~K are the same as Div.1 problems

    Div.2 L: The Euler characteristic shows that $$$V-E+F-C=1$$$ on any planar graph $$$G$$$. So we have $$$C=V-E$$$ and the answer is simply $$$\max(n-m,0)$$$

    Div.2 M: here

    Div.2 N: After convert each portkey to intervals, the problem is essentially the same as CF786B. There will be up to $$$5n+m$$$ endpoints of the interval, but only $$$n+m$$$ of them will be useful. Code

    Div.2 O: The distance of the two points is just $$$d=|x_1-y_1|+|x_2-y_2|$$$, and note that the given graph is a bipartite graph, so the given condition is equivalent to $$$d \geq w$$$ and $$$d\equiv w \pmod 2$$$.

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

For problem K, we had the following algorithm (which gave WA, but we apparently had a proof of):

Root the tree at any vertex which is not a leaf ($$$n = 2$$$ is handled manually), and order leaves in pre-order. Then we will try to pair up leaves such that all paths go through one common vertex (not necessarily that root). This can be done by, say, pairing up the leaves $$$0, \lfloor m/2 \rfloor$$$, $$$1, 1 + \lfloor m/2 \rfloor$$$ and so on, and pair the last leaf with the first leaf.

Our proof was based on the fact that the vertices that are in a path but not in the previous path form at most two chains, and if we root the tree at the common vertex of all such paths, then the chains are no longer candidates for the thief's position.

Could someone point out a counterexample to this algorithm if the proof sounds wrong?

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

Is there somewhere better explanation of problem I? It seems that a lot of important details skipped in the Editorial's explanation.

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

    Assume that the drunkard is at position $$$x$$$, and let $$$\mathrm{dp}_{i,j}$$$ denote the probability of being at moment $$$i$$$ and passing through position $$$x+j$$$ at least once. Obviously $$$x$$$ does not affect the answer, so we only need to focus on the relative distance we are from the end point at each moment. We have $$$dp_{i,0}=1$$$, and $$$\mathrm{dp}_{i,j}=p \cdot \mathrm{dp}_{i+1,j}+(1-p) \cdot \mathrm{dp}_{i+1,j-a_{i+1}}$$$, so we can calculate all $$$\mathrm{dp}_{*,*}$$$ in $$$O(n^2)$$$.

    It's easy to observe that if the relative distance(signed) between the end point and the start point is $$$x$$$, then the probability of passing through $$$x$$$ at least once is just $$$\mathrm{dp}_{0,x}$$$, and the answer is $$$\frac{1}{2n+1} \sum_{i} \mathrm{dp}_{0,i}$$$. Code

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

how to get an account?

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

In problem G, it is not clear how to build the convex hull as for the set of points from example, it will be the monotonous ascending function. Is there any other explanations for problem G ? Endagorion Qingyu

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

Can anyone share the code for Problem B? I don't understand the last part of the editorial