Professional Documents
Culture Documents
Local Selection Contest Solution The Coin Game
Local Selection Contest Solution The Coin Game
My Dictionary 8 My Dog
Just sort the given words in alphabetical order.
Unique Substring(s)
Count the number of occurence of all k-substrings using a map, and output the
one which occurs only once with the smallest starting index.
Robot
The critical part is how do we efficiently execute the repeat command. Create
an array rec which records the x coordinate (x), y coordinate (y) and orientation
(south/north/east/west) (o) of the robot after each command. Given a repeat
command R, i, j, we first find out the robots movement between the i-th and
j-th command. This could be described with (rec[j].x rec[i 1].x, rec[j].y
rec[i 1].y, rec[j].o rec[i 1].o) and rec[i 1].o. Then we can compute the
effect of the repeat command under the robots current orientation by doing
matrix multiplication or simply enumerating all the cases.
Taijitu
Binary search. If we get the i-th symbol after repeating the given process for k
times, then we can find a corresponding flipped symbol generated after k 1
times of flip. Repeat this until you find the corresponding symbol in the original
sequence or in the middle of a sequence (which is always 1).