Hello,
I have tried to solve this problem [Promotions]. It was in SWERC 2015. This problem is reduced to counting successors of every node in a DAG. My best algorithm to solve it is to make a dfs for every node and count the number of reachable nodes. So, the complexity is O(VE), but I got TLE with Java. I checked online solutions and found nothing different (except they are in C++). I wonder if there is a more efficient algorithm, maybe O(V^2) or if someone can provide an efficient AC Java implementation for it.
Thanks!
There is no known algorithm with complexity better than O(VE/32). That one is achieved using bitsets.
In RAM model it is actually O(VE/log(V+E)).
That's interesting. Thanks!
Note that with 64-bit integers used as bitsets, you have V / 64 instead and under the given constraints, that's something like O(80E) per test case. Bitsets are a very useful thing.
ok, I will try it.