We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bool cmp (pair<int, int> &a, pair<int, int> &b) { if (a.first == b.first) return a.second < b.second; // pq는 오른쪽이 기준이기 때문에 second 내림차순 정렬 else return a.first < b.first; // first 내림차순 정렬 }
bool cmp (pair<int, int> &a, pair<int, int> &b) { if (a.first == b.first) return a.second > b.second; // sort는 왼쪽이 기준이기 때문에 first 내림차순 정렬 else return a.first > b.first; // sort는 왼쪽이 기준이기 때문에 first 내림차순 정렬 }
bool cmp (pair<int, int> &a, pair<int, int> &b) { if (a.first == b.first) return a.second > b.second; // second값 기준 오름차순 else return a.first < b.first; // first값 기준 내림차순 (큰 값 우선) }
bool cmp (pair<int, int> &a, pair<int, int> &b) { if (a.first == b.first) return a.second < b.second; // sort는 왼쪽이 기준이기 때문에 second 오름차순 정렬 else return a.first > b.first; // sort는 왼쪽이 기준이기 때문에 first 내림차순 정렬 }
bool cmp (pair<int, int> &a, pair<int, int> &b) { if (a.first == b.first) return a.second > b.second; // second값 기준 오름차순 else return a.first > b.first; // first값 기준 오름차순 }
bool cmp (pair<int, int> &a, pair<int, int> &b) { if (a.first == b.first) return a.second < b.second; // sort는 왼쪽이 기준이기 때문에 second 오름차순 정렬 else return a.first < b.first; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
priority_queue, sort에서의 정렬 방법
차이점
1.
2.
greater 사용하여 정렬
priority_queue
sort 함수
cmp 사용하여 정렬
1. first 큰 값부터 리턴, first 값이 같다면 second 값이 큰 값부터 리턴
priority_queue
sort 함수
2. first 큰 값부터 리턴, first 값이 같다면 second 값이 작은 값부터 리턴
priority_queue
sort 함수
3. first 작은 값부터 리턴, first 값이 같다면 second 값이 작은 값부터 리턴
priority_queue
sort 함수
The text was updated successfully, but these errors were encountered: