karrupt's blog

By karrupt, history, 3 years ago, In English

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?

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it