Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

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

Правка en2, от karrupt, 2022-02-13 17:16:04

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?

Теги custom comparator, sort, runtime error

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский karrupt 2022-02-13 17:16:04 10
en1 Английский karrupt 2022-02-13 17:14:33 990 Initial revision (published)