### rng_58's blog

By rng_58, history, 3 months ago, , How to enter the contest? Comments (52)
 » We can't access with the yandex login. You have to use an opentrains login.
 »
 » Judge is not working now :(
•  » » Our code has been running for 30 minutes. Are there any teams that are having the same problem?
•  » » » We have the same issue.
 » 3 months ago, # | ← Rev. 2 →   Is this some kind of Div2 OpenCup?
•  » »
 » How to solve C and D?
•  » » In C we asked vertices for which we haven't got -1 and with maximal probability to reach edge to another component. This could be estimised by deg(v) — size_connected_component(v)
•  » » » We took the vertex with the highest degree from the smallest component and that also worked well.
•  » » » » I took random vertex (which I haven't got -1) from the smallest component and that also worked well.
•  » » » » » We just picked any vertex (except -1) with the minimal degree
•  » » » » We took arbitrary vertex (ofc that we haven't got -1 already) from smallest component. I don't think degree of the vertex is useful in this case.
•  » » » » » We took the vertex with the lowest degree (don't care about its component) and got AC. Seems like the judges want to make people happy and let everyone pass :D
•  » » » » » »
•  » » » I took a random permutation and asked 2 times for each vertex in the permutation, somehow that got AC.
•  » » » » Wait... But in random graph random permutation ~ $1, 2, \ldots, n$.So is it really working to ask(1), ask(2), ..., ask(n), ask(1), ask(2), ..., ask(n)? (>﹏<)
•  » » » » » Indeed, this problem works in mysterious ways rofl it didn't pass for 1 2 3 4 5 ... n
 » 3 months ago, # | ← Rev. 2 →   Our submissions has not judged in last an hour (still running). Did someone else have the same problem?
•  » » the same
 » How to solve B?
•  » » Enumerate every field in table and xor indices of fields with ones
 » 3 months ago, # | ← Rev. 2 →   No C++11 in a testing system. Judges are still in 2007 or what?! Submissions sent in 04:20 are still running No one answered on our clar submitted at 04:15, and didn't even read it Worst opencup organization ever
•  » » C++0x is basically C++11
 » 3 months ago, # | ← Rev. 3 →   How to solve A without Gauss elimination?
•  » » A could be solved by interpolation. But under this constraints it is not better than gauss
•  » » In A we can use the fact that for every $k\geq d+1$ the following holds: $\sum_{i=0}^k(-1)^i\binom{k}{i}P(a+bi)=0.$Then we choose random $a$ and $b$ and increase $k$ until we get equality modulo $mod$.
•  » » Fact: If $f(x)$ is a polynomial with degree $n$ then $f_{1}(x) = f(x + a) - f(x)$ (with any constant $a$) is a polynomial with degree $n-1$. If we define $f_{k}(x) = f_{k-1}(x + a) - f_{k-1}(x)$ then $f_{n}(x)$ will be a non-zero constant and $f_{n+1}(x) = 0$. The converse is also true. Therefore you can ask integers of form $b+at$ with some random constants $a$, $b$ and compute values of $f_{k}(x)$ accordingly. As soon as we find out $f_{k}(b) = f_{k}(b+a) = 0$ we can determine with high probability that $f(x)$ is of degree $k+1$.
•  » » » ^this
 » How to solve D? We solved it O(N * sqrt(N) * log(N)), but we do not know the verdict yet.
•  » » 3 months ago, # ^ | ← Rev. 3 →   Our solution is $O(N^{3/2})$.Just do sqrt decomposition. It`s easy to deal using some precalculation before the queries with a pair of sqrt blocks (sort each block), with an element and a block (just sort each block and calculate values in increasing order of elements using some pointers for each block), and, finally, after the query you solve for a pair of "pieces of blocks" (using the fact that you can store all sorted prefixes and suffixes of all blocks in $O(N^{3/2})$ time and memory).
•  » » I got AC with your complexity, making the block size as low as possible and getting rid of the log in precalculation. The only part with log was sorting the "pieces of blocks" but that works quite fast since it uses little memory.
•  » » I solve D with Mo + Fenwick Tree + Hard Struggle
•  » » » 3 months ago, # ^ | ← Rev. 3 →   I solved D with $O(n^{1.5}\log n)$ after TLE for 10+ times. And my $O(n^{1.5})$ solution got MLE :(
 » Where is the baobab in the Math&Mech facility?
•  » » 3 months ago, # ^ | ← Rev. 2 →   Top-left corner on this map (from here), medium square hall: Dot on this map: Here is a photo from this website: » So what was the jury interactor's strategy for C?(I hope it's not a secret)
•  » » No strategy, no secret, described in the statement: the graph is random and fixed in each test case.
•  » » » But nothing was said about about how vertices in interactor's responses are chosen(well, except for the samples).
•  » » » » The edges of the graph are ordered (uniformly at random) in advance. Then, for each question about vertex $v$, the answer is the first edge incident to $v$ in that order, or $-1$ if there is no such edge left.This strategy is actually given in the Note section after the example: •  » » » » » 3 months ago, # ^ | ← Rev. 3 →   I thought that this Note is describing a strategy for the example, not for all tests. I don't think that Note is a proper place for jury strategy description :)
•  » » » » » I thought the last sentence only applied to the example tests. Not sure if that was your intention :) But thanks for the answer anyway.
•  » » » » » » Yeah, I see now how this can be misleading.Sorry for the confusion!
 » Our C still in queue.
•  » » three hours after the contest, our D still in queue
 » How to solve G?
•  » » 3 months ago, # ^ | ← Rev. 2 →   You are given $N$ functions of the form $f_i(\theta) = |r_i sin(\theta + \alpha_i)|$, and you want to find $\theta$ that maximizes the sum of $K$ smallest values among $f_i(\theta)$.This sum is a "piecewise trigonometric function" with $O(N^2)$ pieces, so we can explicitly represent this function and compute the maximum.The border between two pieces is a point that satisfies $f_i(\theta) = 0$ or $f_i(\theta) = f_j(\theta)$ for some $i,j$. We should list all such angles and sort them, and do various things carefully.
 » Will be editorial or upsolving?
 » One of our submission is still pending: problem B in Java, at 0:52 during the contest. No response for clarifications. I believe the judge is broken.
•  » » We received "Check failed" verdict for problem B solution on Java during the contest. Switched to C++ to get it judged.
 » How to solve F?
•  » » Greedy. Let's store the answer for each vertex $v$ — the indices of taken decorations in its subtree. The answer for some vertex $v$ is the union of answers for all its children plus $w_v$ values of $v$. Truncate that list to $min(t, w_v)$ most expensive values, that'll be the answer. Use small-to-large and store the answer in a map to achieve $O(n \log^2 n)$.