Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя Ahmad_Elsagheer

Автор Ahmad_Elsagheer, 8 лет назад, По-английски

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!

  • Проголосовать: нравится
  • +9
  • Проголосовать: не нравится

»
8 лет назад, # |
  Проголосовать: нравится +16 Проголосовать: не нравится

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