博客:http://blog.csdn.net/mypsq/article/details/39005991
#include<stdio.h>
#include<string.h>
#define N 30
struct node {
int x,y,xx,yy;
}f[N],ff[N];
int link[N],visit[N];
int main() {
int n,m,i,j,k,cou,index,cnt;
while(scanf("%d",&n)!=EOF) {
for(i=1;i<=n;i++)
scanf("%d%d%d%d",&f[i].x,&f[i].xx,&f[i].y,&f[i].yy);
for(i=1;i<=n;i++)
scanf("%d%d",&ff[i].x,&ff[i].y);
memset(link,0,sizeof(link));
memset(visit,0,sizeof(visit));
cnt=0;
for(i=1;i<=n;i++)
for(j=1;j<=n;j++) {
if(visit[j])continue;
cou=0;
for(k=1;k<=n;k++) {
if(link[k])continue;
if(ff[j].x>=f[k].x&&ff[j].x<=f[k].xx&&ff[j].y>=f[k].y&&ff[j].y<=f[k].yy) {
cou++;
index=k;
}
}
if(cou==1) {
link[index]=j;
visit[j]=1;
cnt++;
}
}
if(cnt!=n) {
printf("None\n");
continue;
}
for(i=1;i<=n;i++)
printf("%c %d\n",'A'+i-1,link[i]);
}
return 0;
}