Run-Time-Error caused by custom compare function

Revision en1, by Bit-Ghifo, 2023-09-26 16:52:17

I got runtime error when using this custom compare function:

bool cmp(char& a, char& b){
	return id[a - 'a' + 1] >= id[b - 'a' + 1];
}

when I changed it to:

bool cmp(char& a, char& b){
	return id[a - 'a' + 1] > id[b - 'a' + 1];
}

I got AC.

does anyone know why did that happen?

lucky for me this didn't happen in a contest.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Bit-Ghifo 2023-09-26 16:52:17 547 Initial revision (published)