Comments

Edit: Money Credited

It is possible to see TC 2 for F question

They considered that, if an edge directed upwards(towards root) then the subtree below that edge as unreachable.

On anmolsainiii23 → Why not Recursive?, 3 years ago
0

apart from (time / space complexity) yours recurrence solution was correct, but generally recursive solution was slower than dp.

On anmolsainiii23 → Why not Recursive?, 3 years ago
0

See the constraint on a, b (1e9). It seems yours code taking O(ab) time and memory

+7

Multi source bfs gives nearest red vextex not farthest

Mint is basically a custom data structure unlike int, long long it has some extra features Once you declare a variable in mint, you can forget about mod operations and can use in a normal way. modular Uncomment required mod. and can declare as modular var;

K can be solved by kinetic tournament, https://codeforces.me/contest/1866/submission/221756159

we can use cartesian tree to get range in O(N)

My solution: https://codeforces.me/contest/1359/submission/208068147