Mahmoud_Hawara

Untitled

Jul 19th, 2022
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define IO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  4. const long long MOD = 1e9 + 7, OO = 1e18;
  5. const double PI = acos(-1);
  6. const int N = 1e6 + 5;
  7. const int dx[4] = {0, 0, 1, -1};
  8. const int dy[4] = {1, -1, 0, 0};
  9.  
  10. long long t, n;
  11. pair<long long, long long>a[N];
  12.  
  13. bool cmp(pair<long long, long long>a, pair<long long, long long>b)
  14. {
  15.     //a.first, a.second - b.first, b.second
  16.     if (a.first < b.first)return 1;
  17.     if (a.first > b.first)return 0;
  18.     return a.second > b.second;
  19. }
  20.  
  21. int main()
  22. {
  23.     IO
  24.     cin >> t;
  25.     while (t--)
  26.     {
  27.         cin >> n;
  28.         for (int i = 1; i <= n; i++)
  29.         {
  30.             cin >> a[i].first >> a[i].second;
  31.         }
  32.         sort(a + 1, a + n + 1, cmp);
  33.         for (int i = 1; i <= n; i++)
  34.         {
  35.             cout << a[i].first << ' ' << a[i].second << '\n';
  36.         }
  37.     }
  38.     return 0;
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment