Ahmad_Elsagheer's blog

By Ahmad_Elsagheer, 10 years ago, In English

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!

  • Vote: I like it
  • +9
  • Vote: I do not like it

»
10 years ago, hide # |
 
Vote: I like it +16 Vote: I do not like it

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)).