Croatian Open Competition in Informatics — COCI 2021/2022
Internet online contest series
As part of the COCI series, we are hosting an Internet online contest with problems from the Croatian Olympiad in Informatics 2022. The contest is primarily intended for high school contestants, but is open to all interested!
This contest is used in Croatia to select members of the IOI 2022 team. There will be three to five tasks and the contest will be five hours long. The contestants will have full feedback with at most 50 submissions per task.
It will be held on Sunday, May 29, starting at 15:00 (GMT/UTC).
Check out your local times at https://hsin.hr/coci/next_contest.html
You may use Python, Pascal, C, C++ or Java as your programming language of choice.
The two relevant websites are:
https://hsin.hr/coci/ — information about the contest
https://evaluator.hsin.hr/ — judging system
We hope that you will join us or encourage your students to do so!
Reminder: the contest starts in less than 30 minutes.
When upsolving will be available?
The problems have now been added to the judging system.
You can access them here under Srednje Škole / 2022 / HIO.
So there will be no Izborne pripreme 2022?
This contest is added up with the Izborne pripreme, so technically it is used to select the IOI team, but yes there will be Izborne pripreme 2022.
My solutions, in case anyone is interested:
Consider each possible centre point of the palindrome in turn (so either a character or the midpoint between characters). Check if it's the centre of a palindrome that's either one or two longer than the previous longest (depending on parity). If so, keep extending it until you hit a non-palindrome, before moving on the next centre point.
The right endpoint increases with each query except that it can stay the same when switching the centre point.
First add 2^20 to both A and B. This won't change their order, and ensures they both have exactly 21 bits. When given A, output every prefix of A with at least 2 bits for which the last bit is a 1. When given B, output each prefix of B with at least 2 bits for which the last bit is a zero, but replace that bit with a 1 in the output. Note that each output array will contain only unique values, because the position of the leading 1 allows the number of discarded bits to be determined.
Suppose a value appears in both lists. Then there is some prefix that appears in both A and B, except that the last bit is a 1 in A and a 0 in B e.g. they are 110101xxx... and 110100yyy.... This makes A > B. Conversely, if A > B then there is a first position where they differ, and A will have a 1 in this position and B will have a 0, and we will find a duplicate. So A > B if and only if C contains a 2.
I found this one the toughest, and I feel like perhaps I missed an easier solution.
Let's consider the people to be nodes in a graph. Paint a node red if it's chosen to be part of the committee, and blue if it is excluded. Initially all nodes are unpainted. We can immediately infer some rules:
If applying these rules repeatedly paints the whole graph, we are done, and the solution is valid: the first rule can only lead to problems when an outgoing neighbour is painted blue (if it ends up without any red outgoing neighbours), but because nodes only become red through the second rule, newly red nodes have all their outgoing neighbours already blue.
However, one may reach a point where no more nodes can be painted using this rule. We can impose an order on the nodes by considering a topological ordering on the strongly connected components, with an arbitrary order within each SCC. Pick the last node X in this ordering which is not yet painted, and identify the set of nodes S reachable from X (including X) without using any painted nodes. The ordering ensures that S can only contain nodes in the same SCC as X. For any node Y in X, if the path from X to Y has odd length, paint it blue, otherwise red (it is unambiguous because if both odd- and even-length paths existed, one of those paths would complete an odd-length cycle with a path from Y to X, which exists because X and Y are in the same SCC). Every blue node in Y must have an outgoing edge to a red node: either it already did, or else it must have started with an outgoing edge to an unpainted node (because rule 2 didn't kick in) and that node will have been painted red. No red node in Y can point at another red node in Y (because they must both be an even distance from X in S), not at a previously-red node (otherwise rule 1 would have kicked in).
Having done this, again apply rules 1 and 2 until it's not possible to continue, and then pick another set S to paint etc.
Use a persistent segment tree. Walk the tree recursively, and when descending into any child, update the segment tree (creating a new view which doesn't destroy the original) with the vignette range for that edge.
I'm pretty sure it's also possible to use a regular segment tree, rewinding changes when exiting a subtree. This requires each node to keep a counter of the number of times the corresponding range has been flagged, rather than just a boolean. To rewind, just decrement this counter again. Note that this structure doesn't allow arbitrary ranges to be removed, just ones that were originally added.
In C I think I proved that each SCC has no odd cycle even if you make edges undirected, so you can paint each SCC as bipartite graph beforehand, then do steps 1 and 2, and if next SCC was not fully painted, paint remaining nodes in it with precalculated colors and continue with regular algorithm.
Btw, your solution looks natural (steps 1 and 2 are the only way to solve for DAG, for SCC my approach takes advantage that the SCC is bipartite, but your approach is more or less the same).
I agree.
I don't think it's quite that simple, because it's not always possible to colour an SCC just according to its bipartite graph. Consider the following graph: 1->2->3->4->5->6->1 (cycle of 6 vertices), plus edges 1->7 and 4->7. The only valid committee is {3, 6, 7}. In this case everything was forced by steps 1 and 2, but I suspect it would be easy enough to find an example where not everything was forced but it was necessary to colour an SCC in a way that doesn't match the bipartite structure.
After applying rules 1 and 2, look at the graph formed by the unpainted vertcies. Every node points to at least one other node, and since the graph is bipartite it always goes to the other "side". Therefore painting one whole "side" of the bipartite graph is enough. So you can apply this process to the SCC which points nowhere and then remove it completely and all nodes from other SCCs which now point to a red node. You can repeat this recursively. This was my solution.
The proof of why my solution works is above. Regarding your example, you actually have an odd cycle on undirected edges (1, 2, 3, 4, 7), which can't exist in SCC.
I'd missed that you only wanted to paint the vertices that weren't already painted. In the example, 7 is one SCC, and 1..6 is another.
Sorry for necroposting but where can I find the standings? I did a virtual contest and want to check how well I did
The official standings: https://hsin.hr/hio2022/rezultati.php
Thank you