#include<iostream> #include<cstring> #include<cstdlib> #include<cstdio> #include<cmath> #include<algorithm> using namespace std; const int maxn=26+5, maxm=1000+10; int T, n, ans, from[maxn], rec[maxn]; bool mmp[maxn][maxn], vis[maxn]; struct point { int x, y; void sc() { scanf("%d%d", &x, &y); } }p[maxn]; struct matrix { int x1, y1, x2, y2; void sc() { scanf("%d%d%d%d", &x1, &x2, &y1, &y2); } bool in(point t) { return x1<=t.x&&t.x<=x2&&y1<=t.y&&t.y<=y2; } }mat[maxn]; void Read() { for(int i=1; i<=n; i++) mat[i].sc(); for(int i=1; i<=n; i++) p[i].sc(); return ; } bool Dfs(int u) { for(int v=1; v<=n; v++) if(!vis[v] && mmp[u][v]) { vis[v]=true; if(!from[v] || Dfs(from[v])) { from[v]=u; return true; } } return false; } void debug() { for(int i=1; i<=n; i++) { for(int j=1; j<=n; j++) cout<<(int)mmp[i][j]; cout<<endl; } return ; } void Work() { printf("Heap %d\n", ++T); memset(mmp, false, sizeof mmp); for(int i=1; i<=n; i++) for(int j=1; j<=n; j++) if(mat[j].in(p[i])) mmp[i][j]=true; ans=0; memset(from, 0, sizeof from); for(int i=1; i<=n; i++) { memset(vis, false, sizeof vis); ans+=Dfs(i); } if(ans!=n) { printf("none\n\n"); return ; } bool flag=false; memcpy(rec, from, sizeof rec); for(int i=1; i<=n; i++) { mmp[rec[i]][i]=false; ans=0; memset(from, 0, sizeof from); for(int j=1; j<=n; j++) { memset(vis, false, sizeof vis); ans+=Dfs(j); } if(ans!=n) { if(flag) printf(" "); printf("(%c,%d)", i+'A'-1, rec[i]); flag=true; } mmp[rec[i]][i]=true; } if(!flag) printf("none"); printf("\n\n"); return ; } int main() { while(scanf("%d", &n)!=EOF&&n) Read(), Work(); return 0; }
|