Comments
+3

Here is my solution to Problem D,may be easier to understand.

Some restriction like:

If we combine these,we can get some scale like L1 <  = k' <  = R1

Then,we need k' be integer which means a1 * k' - a2 * l' = b2 - b1 has integer solutions and . This can be solved used exgcd.

If u are still confused,here is my code.

I have a different idea to solve E which complexity may be O(n).

Each point has only one edge,we can shrink point. This can be done in O(n).

After this, we get a new graph. The new node is a node from original graph or a circle. And we find that each node in this new graph will enter a circle finally.

Suppose u->v1->v2->(circle), k arcs in the circle can calculate in O(1): convert the n node circle to 2*n,cal the prefix sum.

Now we just need to cal the node not in circle dfs v2 then v1 then u, also maintain the prefix sum. So each node res can be done in O(1)

I have not code it, Is that right?

On dalex → Codeforces Round #301 (Div. 2), 11 years ago
0

Why so many people finish Problem B in Div2 quickly,while I spend a lot of time? Is there some tricks or I am stupid?

Thanks a lot. It helps me understand others' code