fork(1) download
  1. #include<stdio.h>
  2. #include<deque>
  3. #include<algorithm>
  4. using namespace std;
  5. class node{
  6. public:
  7. int x,y,num;
  8. }dum;
  9. bool func(node i,node j)
  10. {
  11. if(i.y > j.y)
  12. return true;
  13. return false;
  14. }
  15. int main()
  16. {
  17. deque<node> city;
  18. int n; scanf("%d",&n);
  19. for(int i=0;i<n;i++)
  20. {
  21. scanf("%d %d",&dum.x,&dum.y);
  22. dum.num = (i+1);
  23. city.push_back(dum);
  24. }
  25. if(n == 0)
  26. {printf("0");return 0;}
  27. sort(city.begin(),city.end(),func);
  28. for(int i=0;i<n;i+=2)
  29. {
  30. printf("%d %d\n",city[i].num,city[i+1].num);
  31. }
  32. }
Success #stdin #stdout 0s 3244KB
stdin
4
0 2
1 1
3 4
4 4
stdout
3 4
1 2