fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int t;
  7. cin >> t;
  8. while(t--){
  9. int n;
  10. cin >> n;
  11. vector<pair<int,int>> vp;
  12. for(int i=0;i<n;i++){
  13. pair<int,int> p;
  14. cin >> p.first >> p.second;
  15. p.second *= -1;
  16. vp.push_back(p);
  17. }
  18.  
  19. sort(vp.begin(),vp.end());
  20.  
  21. for(int i=0;i<n;i++){
  22. cout << vp[i].first << " "<< -1*vp[i].second<<endl;
  23. }
  24.  
  25. }
  26.  
  27.  
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0.01s 5460KB
stdin
1
5
3 4
-1 2
5 -3
3 3
-1 -2
stdout
-1 2
-1 -2
3 4
3 3
5 -3