Advertisement
Diene

Untitled

Mar 2nd, 2018
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main ()
  4. {
  5.  int repeticoes;
  6.  scanf ("%d", &repeticoes);
  7.  for (int i = 0; i < repeticoes; i++){
  8.   int quantidade;
  9.   scanf("%d", &quantidade);
  10.   vector < pair< int, int> > pares(quantidade);
  11.   for (int i = 0; i < quantidade; i++){
  12.    scanf ("%d %d", &pares[i].first, &pares[i].second);
  13.   }
  14.      sort(pares.begin(), pares.end());
  15.      
  16.   for (int i = 0; i < quantidade; i++){
  17.    if (pares[i].first==pares[i+1].first && pares[i].second < pares[i+1].second){
  18.    swap (pares[i], pares[i+1]);
  19.    i=0;
  20.    }
  21.   }
  22.   for (int i =0; i< quantidade; i++)
  23.    printf("%d %d\n", pares[i].first, pares[i].second);
  24.  }
  25.  return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement