Let's discuss problems here.

By Shayan

Stream is running

# | User | Rating |
---|---|---|

1 | ecnerwala | 3648 |

2 | Benq | 3580 |

3 | orzdevinwang | 3570 |

4 | cnnfls_csy | 3569 |

5 | Geothermal | 3568 |

6 | tourist | 3565 |

7 | maroonrk | 3530 |

8 | Radewoosh | 3520 |

9 | Um_nik | 3481 |

10 | jiangly | 3467 |

# | User | Contrib. |
---|---|---|

1 | maomao90 | 174 |

2 | adamant | 164 |

3 | awoo | 163 |

4 | TheScrasse | 160 |

5 | nor | 158 |

6 | maroonrk | 156 |

7 | SecondThread | 150 |

8 | -is-this-fft- | 147 |

9 | pajenegod | 146 |

10 | BledDest | 144 |

Let's discuss problems here.

↑

↓

Codeforces (c) Copyright 2010-2024 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Apr/12/2024 21:30:46 (l2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

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

Editorial

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 ?

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).

SolutionThank you bicsi !

better coded than ours :). An observation: the final complexity is $$$O(n \sqrt q)$$$.

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:

Thank you ATSTNG ! Obviously, linked list is better than set.

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

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

Thank you Qingyu ! Very interesting observation.

Is there any div.2 editorial available?

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$$$.

for N, it is possible to use BFS also.

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?

The problem is that leaf $$$\lfloor m/2 \rfloor$$$ can be in the middle of a subtree. If you first scan half of the subtree, then later the other half, the bad guy could move between the two parts of the subtree.

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

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

how to get an account?

You should probably ask one of closest sector's admin or register new sector. All information is here.

How to find one of closest sector's admin?

I don't know, maybe it would be a good solution to ask in [email protected].

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

My teammates just checked 50 points around)) I don't know why it works.

AmDer Can you send your solution ?

Wow, it's 32 in the last send!

SolutionThank you AmDer !

Maybe someone from Div.1 will be able to explain this problem ?

When we iterate $$$c$$$ over $$$X$$$ in ascending order, the slope of some lines increases. All we need to do is add a new line to the corresponding position. This can be done by using Li Chao Tree or convex hull trick.

Know, everything is clear for me about convex hull trick. But how that function is corresponded to this trick ? Where is k,b,x ? Qingyu Endagorion

And what does this function fc(y) mean? As far I understand it doesn't count loose. Qingyu

I would be thankful, if someone, maybe from Div1 will help me to understand the solution.

Thank you Qingyu,mtw! It is clear now.

google convex hull trick

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