std::stable_sort 함수를 사용하려면 random access (operator[] 연산자를 사용하여 임의의 원소에 O(1) 시간에 접근)가 가능해야 합니다. 하지만 C++에서는 list가 linked list 기반으로 구현되어 random access가 불가능하기 때문에 컴파일이 되지 않는 것입니다.
list를 vector로 바꾸면 해결될 겁니다.
C++ 표준에 따르면 작동하지 않는 코드인데 질문자님 로컬에서는 왜 작동하는지 궁금하네요. 아마 compiler extension이라고 해서 C++ 표준으로는 지원하지 않지만 해당 컴파일러에서 지원하고 있는 기능이라서 컴파일이 되는 것 같습니다.

rlatjddyd92 2년 전
VS에서는 정상적으로 작동하고 답도 잘 나옵니다.
그러나 제출을 하면 stable_sort 를 사용한 코드(49,51번째 줄)에 [required from here] 메시지가 뜨며 하단에는 다음과 같은 내용이 나오면서 컴파일 에러가 납니다.
//
required from ‘void std::stable_sort(_RAIter, _RAIter) [with _RAIter = std::_List_const_iterator<int>]’!error: no match for ‘operator-’ (operand types are ‘std::_List_const_iterator<int>’ and ‘std::_List_const_iterator<int>’)! required from ‘void std::stable_sort(_RAIter, _RAIter, _Compare) [with _RAIter = std::_List_iterator<Location>; _Compare = main()::<lambda(Location, Location)>]’!error: no match for ‘operator-’ (operand types are ‘std::_List_iterator<Location>’ and ‘std::_List_iterator<Location>’)
//