Solution to GCJ2015 QR
Standing Ovation
Use a variable s to store the number of people who will stand up now.
Iterate i from 0 to n, if i is greater than 0 and s is less than i, we add i - s to
the answer and increase s to i. And then, we add s_i to s.
Infinite House of Pancakes
Enumerate the maximum number of pancake a plate contains after the adjustment.
If a plate contains more pancake, we can compute the minimum number of adjustment for this plate.
We sum up all the necessary number of adjustment and obtain an possible answer, then, find the
smallest one.
Dijkstra
First, we need to check whether the value of the input expression is -1.
Second, notice that D^0, D^1, D^2, D^3 will be cyclic. If the answer exist, there must exist
a tuple (u, v) such that D^u*D[1..u] = i, where u is not very large. There exists a tuple (s, t)
such that D[t..L]*D^s. We can enumerate u and v, and find the minimum v and the maximum t and
compute the character used to obtain i and k. If it's no more than L*X, then we have a solution.
Ominous Omino
It's obvious that if n is greater than 6, Richard can always win, because he can choose a
shape with a hole. When n is less than 3, it's very easy to solve. Then we should consider
the left situations: n is in the range of [3, 6]. The key point of checking whether a shape
is a win for Richard is to check whether all the connected component is divisible by n after
placing the shape. If min(r, c) is greater or equal to n, Richard will lose. If there exist
a shape which can not be placed in the grid, Richard will win. Enumerate all the shape (including
rotation of one shape) and enumerate all the cases it can be placed in the grid and check.