stl pair

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<time.h>
#include<map>
#include<set>
#include<algorithm>
using namespace std;

pair<int,int>p[1000];

int main( )
{
  int N,M;
  while( scanf("%d",&N) != EOF)
  {
     srand(time(NULL));
     for( int i = 0; i < N; i++)
     {
        p[i] =  pair<int,int> (rand()%10,rand()%10);
     }
     sort(p, p + N);
     for( int i = 0; i < N; i++)
     {
        printf("%d %d\n", p[i].first, p[i].second);       
     }
     int a, b, x;
     for( int i = 0; i < N; i++)
     {
         scanf("%d%d%d",&x, &a,&b);       
         pair<int,int> temp1, temp2;
         temp1 = pair<int,int>(x,a);
         temp2 = pair<int,int>(x,b);
         printf("%d %d\n", upper_bound(p, p + N,temp1) - p, lower_bound(p, p + N, temp2) - p); 
            
     }
  }
  return 0;
}

posted on 2012-10-05 21:02  more think, more gains  阅读(205)  评论(0编辑  收藏  举报

导航