#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
struct node{
int x;int y;
}list[1002],list1[1002];
bool cmp(node a,node b){
if(a.x==b.x)
return a.y<b.y;
else
return a.x<b.x;
}
int main(){
int n;
int i;
int icase=1;
while(scanf("%d",&n)&&n!=0){
for(i=0;i<n;i++){
scanf("%d%d",&list[i].x,&list[i].y);
list1[i]=list[i];
}
sort(list1,list1+n,cmp);
printf("Case %d:\n",icase++);
for(i=0;i<n;i++){
int kk=0;
while((list[i].x>=list1[kk].x||list[i].y>=list1[kk].y)&&kk<n)
kk++;
if(kk<n)
printf("%d %d\n",list1[kk].x,list1[kk].y);
else
printf("-1 -1\n");
}
printf("\n");
}
return 0;
}
/**************************************
Problem id : SDUT OJ 2158
Result : Accepted
Take Memory : 496K
Take Time : 0MS
Submit Time : 2013-05-18 22:31:35
**************************************/
sdut2158 Hello World!
最新推荐文章于 2015-04-27 20:53:31 发布