ayush29azad's blog

By ayush29azad, history, 5 weeks ago, In English

Yesterday 's contest had some very good problems , unfortunately, it became unrated.

Problem Link : https://codeforces.com/contest/1573/problem/C

The problem is based on standard topological sort Prerequisite problem .

If the cycle was found in the graph I printed -1 as the answer.

else I found the topical sort of all the chapters , using cycle detection + DFS + queue.

After finding the topological ordering of chapters (stored in a queue a ->b->c->d.... )how do I count the number of times I will have to read the book/number of passes required ???

Please help !!!

 
 
 
 
  • Vote: I like it
  • -3
  • Vote: I do not like it

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by ayush29azad (previous revision, new revision, compare).

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by ayush29azad (previous revision, new revision, compare).

»
5 weeks ago, # |
  Vote: I like it +1 Vote: I do not like it

you can use dp to find the answer.

dp states
transitions
submission

hope it helps!