Help on problem Johny and Contribution

Revision en1, by The_mysterio, 2020-06-06 13:16:59

Kindly help me with the solution of this problem https://codeforces.com/contest/1362/problem/D My solution https://codeforces.com/contest/1362/submission/82683708 Please help me to find out my error.It seems to me ,the statement *s.rbegin()!=s.size() is causing the problem but not finding any test case to understand why it should be wrong.. My algorithm is as follows... 1)check whether any two neighbouring vertices have same topic--->statement arr[i]==arr[u] does that where u is neighbour of i. 2)if not same,then I map the topic values given, to values starting from 1.So if the topic values avaialable are 2,4,5 then I map 2->1,4->2,5->3. The reason is I will be checking the condition as to whether there exists a topic number smaller than the topic number of current vertex being processed such that the current vertex has no edge to any other vertex having that smaller topic number. So,this mapping is stored in the mapping array. then I process each vertex and its adjacent vertices.The topics of the current vertex as well as the adjacent vertices are pushed into set s.Now if the above stated condition in the previous paragraph holds,then the last element of this set will obviously be not equal to size of the set.So we will be printing -1. Is there some misundrstanding here? Thanks in advance to anyone who will help this novice coder...

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English The_mysterio 2020-06-06 13:16:59 1408 Initial revision (published)