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

Автор uttom, история, 8 лет назад, По-английски

Problem Accepted Solution Runttime error code

I sort some value that are stored in some vector(2D) lst[]

bool cmp(i64 a,i64 b){
 return a>b
}
sort(lst[i].begin(),lst[i].end(),cmp)

This is my accepted code customize sort

In second code

bool cmp(i64 a,i64 b){
 return a>=b
}
sort(lst[i].begin(),lst[i].end(),cmp)
This code got Runtime error.

My question is that if my customize funtion in 2nd code is

wrong then My verdict will be Wrong but why Runtime Error. Thanks in Advance.

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

»
8 лет назад, # |
  Проголосовать: нравится +23 Проголосовать: не нравится

I think it is because the compare function must return false for equal elements. You can go to this link (http://www.cplusplus.com/reference/algorithm/sort/)