Problem A. And Xor Tree
Score: .
Since we only care about squaring, we can enumerate the contributions generated by the two bits . Then you turn all the numbers into integers between . Feel free to dp it.
Problem B. Balanced Permutations
Score: .
I can’t do it, and the official problem solution isn’t very complete.
It’s probably just that you build the Cartesian tree and find that it’s pretty average. I’m not too good at the specifics.
Problem C. Cyclic Shifts
Score: .
Good question!
You notice that doesn’t do much, and you note that presumably means swapping two elements (if you treat the original sequence as a ring). Further, it is possible not to select consecutive positions so that several positions are exchanged at the same time, which would cost no more than .
With parity sorting, we can use exactly operations to order the original sequence, where since we are treating the original sequence as a ring, we have to do exactly operations in order to get rid of the effect of the cyclic shifts.
Problem D. Distinct Subsequences
Score: .
Consider a subsequence automaton that matches greedily. The complexity is too high, how to optimise?
We split the original sequence into left and right segments of roughly equal length. After each solve segment, we return a few dp indicating the number of matches that can’t be made in if the current length is , starts with and is followed by . ( is in fact the number of matches that can’t be made in . ( is actually all the legal numbers).
Consider how the information returned by can be used to calculate the information for . It is easy to see that for a legal string, there are two cases:
- Case : the subsequence only passes through . Superimpose the information.
- Case : the subsequence passes through , so the beginning of the subsequence on that side of cannot be added to .
This completes the transfer.
Using NTT convolutional optimisation this can be done .
Problem E. Epidemic Escape
Score: .
For a critical point , make a plumb line . Then if the escape route touches the defence is reduced by one. The problem becomes the th straight line through which a ray passing through the origin passes.
Pull out the convex envelope that surrounds , then delete those edges and pull out the rest of the edges to make the convex envelope. Do this times. For the query, for convex packets, we add all edges next to the ray to the preselected answer, and output the th smallest preselected answer.
Problem F. Five Letter Warning
Score: .
Enumerate the centre of the echo, assuming denotes the number of substrings in . denotes the number of substrings in .
Then you find that the time, space complexity is .
You find that space can be rolled off, and time can be done in time for two adjacent with only elements changed.
Problem G. Gridlandia
Score: .
Constructed Question. Will not.
Problem H. Holiday Regifting.
Rating: .
Actually, the order in which the elf hands out the gifts is not necessary. We can solve all the requirements of in turn.
Maintain , initially . Maintain the gifts received by each person at time. Enumerate sequentially.
- If when , then just push the gift to the back.
- Otherwise, we need to double time, specifically, doubling and then just doubling all the that follow.
Time complexity .
Problem I. Julienne the Deck
Scoring: .
If the answer is , otherwise the answer is .
Problem J. Knight’s Tour Redux
Score: .
Slap this plane flat and only care about the transformations on your rows and columns. You find that only is unsolvable.
You find that has a construction going from to . You can then generalise the construction.