A - 3,2,1,GO
Very easy.
1 | n = int(input()) |
B - Split Ticketing
Just a simple loop.
1 |
|
C - Puddles
DFS 或者 BFS 都可以解.拓展到一个新格子时,检查是否在边界即可.
1 |
|
D - Minimize Range
Suppose we always sort they array increasingly. Then
First of all, we can always conclude that , because otherwise, we can add to to decrease the difference. This gives .
Now, the minimum possible answer can only be attained by increasing , because if we add to , then either the difference remains the same, or and the difference cannot be smaller. Given that , it’ll take at most times of operation to increase all elements by .
So we can use an ordered set to keep track of the order. The time complexity is .
1 |
|
E - Fibonacci String
The first step is straightforward. Suppose we have a function that tells the number of character in . Then the answer is just .
So the next step is to compute efficiently given . Note that is formed by concatting . So, by binary searching on length of , we can locate . Suppose we know that some satisfies , then we can simply add to the final answer, and reduce to search on .
This gives a solution for a single . So the total complexity is
1 |
|
F - Strongly Connected 2
Assume we have sorted edges by src point. One observation is that, since can reach if , so is SCC iff can reach . Let be the number of solution to make be strongly connected by only considering the first edges.
Initially, all except that . Now consider edge ,
- For or , whether accept or reject this edge does not affect the existing solutions. So
- For , we must not accept this edge, because it will make existing solutions able to reach nodes larger than . So
- However, for , this edge enables more solutions which end at . So
We can do in-place modification with segment tree. So the total complexity is .
1 |
|