Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <vector>
- bool compare(std::pair<size_t, size_t> const &first,
- std::pair<size_t, size_t> const &second) {
- if (first.second == second.second) {
- return first.first < second.first;
- }
- return first.second < second.second;
- }
- int main() {
- size_t n;
- std::cin >> n;
- std::vector<std::pair<size_t, size_t>> arr(n);
- for (auto &pair : arr) {
- std::cin >> pair.first >> pair.second;
- }
- std::sort(arr.begin(), arr.end(), compare);
- for (auto const &pair : arr) {
- std::cout << pair.first << ' ' << pair.second << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement