Please read the new rule regarding the restriction on the use of AI tools. ×

Runtime error Vs no Error with a difference of '='

Revision en1, by karrupt, 2022-02-13 17:14:33

I just want to know what is the difference between the two scenarios given below: (a similar thing happened with me in the 1551B2 problem) COMMON SCENARIO FOR BOTH CASES: we create a 2-D vector(just like we do for graph input). now let's say we take some edges input. ( loop(i, 0, n-1){ll a, b; cin>> a >> b; g[a].pb(a), g[b].pb[a];} ) now we sort the graph using comparator; condition of comparator is to sort the 2-D vector according to the size of 1-D vector in decreasing order; THE DIFFERENCE is in two comparator used : one gives AC and other gives runtime error (of course not on all cases runtime error occurs):

scenario 1-> bool comp(vectorv1, vectorv2){ return v1.size() > v2.size(); } scenario 2-> bool comp(vectorv1, vectorv2){ return v1.size() >= v2.size(); }

One scenario is getting accepted while the other is giving runtime error. I don't know why? can someone please help?

Tags custom comparator, sort, runtime error

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English karrupt 2022-02-13 17:16:04 10
en1 English karrupt 2022-02-13 17:14:33 990 Initial revision (published)