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

Автор reaper28, история, 5 лет назад, По-английски

question : https://codingcompetitions.withgoogle.com/kickstart/round/000000000019ff43/00000000003379bb solution : https://ideone.com/u8gzBD Why is it giving WA please help anyone... I have maintained which character comes under which in an array neeche[26] . i have made the graph using that array and done bfs for output.

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

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

According to me your initial idea is perfectly fine, I mean the approach while creating the array. But there may be many indirect connections too, which can make an element dependent of an other element which it is not directly connected. I don't think your code handles that portion(I may be wrong). You can check all the dependencies by simply performing topological sort using Kahn's Algorithm by creating a directed graph based upon the dependencies. Here's my code if you want to take a look : https://ideone.com/TUerfZ