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

Блог пользователя karrupt

Автор karrupt, история, 3 года назад, По-английски

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?

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится