Yesterday I also realized that the distribution of this problem is not good (only 20, 90-100 assuming most people got subtask 1, which is relatively easy). During the yesterday's GA meeting, I raised a minor objection about this. However, the answer from the ISC is satisfying (believe me), so now I am agree with the scoring :)

My opinion is that the curve should be similar regardless of difficulty. Now contestants who happens to suddenly don't know how to do / have bugs are severely punished. Now it seems that the whole IOI (bronze) will be decided by this 70 points.

To summarize what was told on the stream, the judging system still doesn't seem to work well, there's a big queue and it's not clear when the contest will end. So far it seems that it has been extended by 15 more minutes, for total duration of 5:30.

OK, so that will be some fair amount of work :P. I am really surprised by some similarity of this problem to ... some other problem :P (details in spoiler)

Simurgh solution

Let's start with solution that does <=m queries. It's obvious that if an edge is a bridge that it is a royal road. We will focus on taking an arbitrary spanning tree T and determining for every of its edges whether it's royal. In order to do this we will demand even more. For every vertex v we will fix one of edges that determines its low value (one we compute when determinining bridges etc.). Let's call set of such edges as L. We will determine which roads from L are royal as well, but just as an auxiliary result.

Let's look at two trees T1 and T2 so that T2 is obtained from T1 by removing edge e1 and adding edge e2. If C(T2) = C(T1) + 1 (where C is shorthand for count_common_roads function) then we know that e2 is royal and e1 isn't. Similarly if C(T2) = C(T1) - 1. Call it exchange lemma.

Now let's look at some cycle in our graph. Let it consist of edges e1, ..., ek. We can create a tree Ti that has all edges from this cycle except ei and all such trees has same set of roads except this cycle. From exchange lemma if it is the case that some of edges from this cycle are royal, but some aren't then we will easily determine for every edge whether it is royal or not. It can't be the case that all edges from cycle are royal, so otherwise no edges are royal, so we know everything as well.

Let's return to our goal, determining which of edges from T and L are royal. For start let's ask about C(T). For every edge e from T that is not bridge let's ask about C(Te) that is created from T by removing e and adding edge that determines low(v), where v is its deeper (in spanning tree) vertex. Moreover for every edge e in L ask for C(Te) that is T with added e and removed edge from spanning tree that is highest of T's edges lying on a cycle formed in T with added e.

So we know R(e1) - R(e2) for some pairs of edges e1 and e2, where R(e) = 1 iff e is royal or 0 otherwise. We can create a graph G whose vertices are edges of original graph from either T or L and two vertices (corresponding to original edges) are connected with directed edge if we know difference of R when applied on them. If we take a connected component in such graph and at least one of differences is nonzero we easily determine R values on all of such vertices/edges. We can note that if our original graph is biconnected (and has >2 vertices) then graph G is connected and since it contained cycle we know that if all differences are zero then no edges from T or L are royal. That fact applied to all biconnected components of our original graph leads to algorithm of determining royality of all edges from T and L. But we can forget about L, we will use just T from this point on.

Now for every edge e not from T or L we can create a tree Te that has edge e and n - 2 of edges from T that together with e form a tree. We can ask about C(Te) and from exchange lemma we will determine R(e). This leads to a solution scoring 51 points (maybe there is simpler way of getting that many, but this solution can be further extended to get 100 pts)

Now we can move on to solution using queries instead of O(m). On beginning let's observe that if we have set of edges F that forms a forest we can know how many of its edges are royal by adding edges from T as long as they do not form a cycle and asking about number of royal edges in resulting tree. Since we know which of edges from T are royal we just subtract number of added royal edges from T from the result of C query. However we will use this just for F sets that are stars.

Let's fix a vertex v, we will determine all edges incident to v that are royal and are not from T. If there are k of them we will use at most queries. We do this in almost the same way as in prize problem, similarity between these two problems is really big. Let Ev be set of edges not from T that are incident to v. We can learn what is C(Ev) (abuse of notation since Ev is not a tree, hope that it is clear). If it is zero then we conclude there are no interesting edges here. If it is k > 0 we then ask about C(H) where H is a first half of Ev. If C(H) > 0 then we recursively find all royal edges in H and if C(H) - k > 0 then we recursively find all royal edges in second half of Ev. It's kinda like a binary search that tries to find multiple objects instead of just one. That results in queries that are needed to find all royal edges incident to v what gives queries in total. We are almost done, but this slightly exceeds query limit, because it is something like , because for edge uv we use queries when searching through u's edges and queries when searching through v's edges. To fix this, when we browse v's edges we not only discard ones that are from T but also ones that go to vertices with lower index. That concludes solution which uses at most queries and gives 100 pts.

1) There's a lot of least valuable boxes and just a few of more valuable ones 2) Try determining at least one 3) If we have two of them, how can we tell whether there is more valuable one between them? How to use this fact to look for more valuable boxes?

In order to make my number of queries lower I noted that if sum of two values returned by checker is at least 22 then it is least valuable, because (222)2 > 200000. That allows me to ask about only 23 boxes.

Let's define the boxes which are not the cheapest as good boxes. At first, use 472 queries to get the total number of good boxes, x. 472 are enough since x ≤ 472. And then use a function f(left, right, number of good boxes with indices < left, number of good boxes with indices > right) to locate and search for the good boxes by "binary search with multiple targets" (maybe it has a specific name?).

My approach for 100 marks

Assume the total number of good boxes, x, is 0. Then directly use the function mentioned above without the initial 472 queries. If a query gives a sum larger than x, update x by that value. After every query and every recursive call done in f, if x is updated, do everything again inside that call including the recursive calls. Make sure that the answers from the queries before are stored to prevent multiple queries for the same box.

Hi, i was kinda frustrated, now i'm much better (i gotta thank everyone for their consolations, my family, friends, people of cf and a lot more, thank you everyone) About the problems, i liked them, but they were too hard for me to solve, there were a lot of strong participants that managed to solve them, congrats (especially yutaka1999 for that impressive win, both on IMO and IOI) I enjoyed this wonderful event, despite how i performed, hope everyone else enjoys it aswell

Pedrohso is an incredibly talented guy. I feel very proud by having taught him a few classes a while ago, and I'm happy he could overcome his past coding limitations and was able to fully showcase his problem solving skills. We Brazilians are all very excited about this result, which hopefully will get official soon! :D

At this point, I haven't even got the confirmation that day 1 results are final, and I have suspicions that they might not be, which is why I did not publish even preliminary results to the statistics.

You don't have to wait for the judge to finish to resubmit. Also, in the last 15 minutes, submissions have no minimum interval. So submitting twice in the last minute is very normal...

I was lucky enough to sit next to him this year. He told me after the contest that he submitted in the last few seconds for Q5. He was very happy to find out 3 hours later during analysis time that he received 100 points :)

Sure, submitting twice is normal. I want to know if he was making random changes and submitting or if he miraculously found a bug in the last few seconds, debugged instantly and squeezed in a correct submission three seconds before the contest ended?

Lol. Care to elaborate what you mean, just a suggestion :)? There are a lot of ways you can think about this problem and there are a lot things you can simply don't care about if S=0. Don't expect us to know what you mean by "logic for S=0"

When S=0 I know a O(n) solution what merges cycles. Otherwise, I can't imagine how to count the amount of walking from starting point to largest cycle covering it. I have a dijkstra solution what works in O(n^2) because I need to check if i can travel from one cycle to another...

How to lost your medal: Solve problem Prize under the impression that the checker is not adaptive, random 5 times instead of 500 times, spent 3 hours trying to optimize the binary search part without realizing that the checker is adaptive. Profit.

Here is another example. I had Prize coded hour and a half in the contest, and it was correct with one tiny error: my bs was while l < r instead of l <= r, and I spent 3,5 next hours debugging it. I found my error literally minute until the end of the contest, fixed it, submitted, and then I realised I have commented a part of my code, for some kind of debugging. I deleted the comment, alt tabbed to the cms, but it was too late. In the analysis, that solution was accepted, without any changes. :(

When looking on the submission for Simurgh by 9-th placed Lukas Michel, we can observe, that he first solved subtasks 1-3 and in the very last submission only subtask 4. (Probably some other such submissions can be found)

Sure enough, in the rules we can read The score for each task will be sum of scores for its subtasks.

What is the reasoning behind such scoring? Sure, it benefits the participants. But, essentially, participants might produce multiple partial solutions, instead of one that solves all subtasks. What are your thoughts, community?

...and this is indeed what participants did, and indeed more or less what the jury expected them to do.

It's totally okay for participants to write partial solutions — indeed that is exactly what the entire concept of subtasks is for. Often it makes no sense to try to write a single solution that solves multiple subtasks: a reasonable IOI participant who cannot solve some problem completely might be able to solve subtask 1 with a bruteforce, and subtasks 2 and 3 might happen to be different special cases that can each be solved with a different special case solution. Requiring this participant to combine all three in a single file is just a waste of their time.

Thus the introduction of the "sum of scores of subtasks" rule doesn't really change anything about the spirit of the competition, but it does fix some awkward things that might happen without it, especially when feedback is broken (and I remember more recent IOIs where feedback was broken at some point than IOIs where it never was). Here's an anecdote that hits close to home: our own OVR in 2012 submitted a solution to some problem that solved subtasks A, B, C. Then feedback was broken (and never got fixed before the end of the contest), and OVR submitted another solution, which happened to solve A, B, D, but broke on C for some reason. Because of the broken feedback, he never learned about this until after the end of the context. (score(ABCD) — max(score(ABC), score(ABD))) would've been enough points to move him from bronze to silver, and the team wrote an appeal arguing that, if feedback was working as intended, he'd have noticed this and just submitted a "merged" solution that invokes his old one when ran on tests from subtask C. The appeal was almost granted, until someone from the jury noticed that the second submission was made less than a minute before the end of the competition, which meant it was quite unlikely he'd have managed to do the merging in time, so the appear was eventually denied. Had the new rule been in place back in 2012, Latvia would've had one more silver medal :)