Advertisement
add1ctus

Chef and Polygons

Jun 10th, 2015
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <algorithm>
  3. #include <utility>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int t,n,m,x,y;
  10.     scanf("%d",&t);
  11.  
  12.     for(;t>0;t--)
  13.     {
  14.         scanf("%d",&n);
  15.         pair<int, int> rightMost[n];
  16.         int result[n];
  17.         for(int i=0;i<n;i++)
  18.         {
  19.             rightMost[i].second=i;
  20.             rightMost[i].first=-999999999;
  21.             scanf("%d",&m);
  22.             for(int j=0;j<m;j++)
  23.             {
  24.                 scanf("%d%d",&x,&y);
  25.                 leftMost[i].first=max(rightMost[i].first,x);
  26.             }
  27.         }
  28.         sort(rightMost,rightMost+n);
  29.         for(int i=0;i<n;i++)
  30.             result[rightMost[i].second]=i;
  31.         for(int i=0;i<n;i++)
  32.             printf("%d ",result[i]);
  33.         printf("\n");
  34.     }
  35.  
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement