Problem A. Elevator
You can either check all four cases or notice, that if we consider front/back equal to 0/1 (b) and decrease a by 1, then a XOR b became the answer (0/1). Time and memory consumption - O(1).
Problem B. Quiz League
Just write one loop: while kth question has already been asked, increase k by one and if k > n let k = 1. Time and memory consumpiton - O(n).
Problem C. Winnie-the-Pooh and honey
One of the possible solutions is direct emulation. Winnie won't do more than 3n iterations (because he can use each jar more than three times). You can emulate each iteration in O(n) (just find maximum in array). Summary time - O(n2) ≈ 104 operations, memory consumption - O(n)
There is another shorter solution: let's notice that order of jars doesn't matter. Let's see how much honey from each jar will be eaten by Winnie and how much will be left to Piglet. If ai ≥ 3k then Winnie will leave ai - 3k kg of honey to Piglet. If ai < 3k then he'll leave only kg. Now solution is one loop. Time and memory consumption is O(n).
Problem E. Put Knight!
Petya wins if n is odd, Gena wins if n is even. It's quite easy to prove - just do symmetrical turns.
Problem F. Spiders
Answer is sum of all spiders' lengths. Use depth-first-search (started at all vertexes) to calculate length of each spider.
Problem G. Boom
It's simple realization problem. All you need is two-dimensional arrays and one queue. Code
Problem H. Brevity is Soul of Wit
Notice that there are only different strings that have length 4 or less. Then notice that each of input strings you can change to different short words at most (|wi| is length of the ith word).
Now let's make bipartite graph. One part is all source words, the second part is all short words and there is edge if and only if we can change word from the first part to the short word from the second part. Now our task is just find perfect matching in this graph. It can be done in O(n1· m) ≈ 200· 200· 385 = 15.4·106 operations which is enough.
Problem I. Luck is in Numbers
Unfortunately, my solution for this problem is rather big. If someone know beautiful one share it please.
The main idea is very standard: let's fix some prefix of number, which is strictly greater than such prefix of source number. If we can get known what is maximal happiness for suffix of our number then we can solve the problem by just running down values for each number in suffix and checking that we still can reach necessary value of happiness.
Now solution for this subproblem is just to fill suffix with eights and calculate the answer. It's good but takes a lot of time. We need to store old values and recalculate its in O(1). There are very simple formulas to do it.
Problem J. Minimum sum
Firstly you need to notice that you can turn all vectors in such way that all of them have non-negative coordinates and the answer will remain the same.
And now we have the following problem: find two nearest points from the given set. It's standard divide-and-conquer problem, it's described in Wikipedia.
Also there is simpler solution (added by diogen): let's sort all our points by distance from a random point far-far away. It's oblivious that if some points lie near each other, distance to this far point doesn't vary a lot. And now solution is run down for each point C points near it in the sorted array. C about 200 is enough to got Accepted.