Topological sorting-annoying slides

Source: Internet
Author: User

Annoying slides

Description

Professor Li made a very important speech this afternoon. Unfortunately, he is not a very neat person, he put his speech to use the slides randomly stacked together. So he had to tidy up the slides before the speech. As an efficient scholar, he wants to do it as easily as possible. In this case, the professor will have to use a total of n slides (n<=26), the N-slide in accordance with the order of the speech to be used by the number 1,2,...,n has been numbered. Because the slides are transparent, we can't see the slides that correspond to each number at a glance. Now we use capital letters A,B,C, ... Once again the slides are numbered, as shown in the example, we can quickly find that the slide number A is the 4th one, after we draw it out we can be sure that the slide number C is 2nd, ... Your task is to write a program that corresponds to the numeric number of the slide and the letter number, which obviously should be unique; if there are multiple correspondence, or if some numbers and letters don't correspond, we call the correspondence impossible.

Input

The first line has only one number n, which indicates that there are n slides, and the next n rows contain 4 integers xmin,xmax,ymin,ymax (separated by spaces), the coordinates of the slide (the area is a slide), and the n slides are numbered a from front to back in the order in which they appear in the input file. , B,c, ... The next n rows are sequentially n numbers of coordinates x, Y, and obviously there is no number outside the slide.

Output

If the corresponding can be achieved, your output should include n lines, each action a letter and a number, the middle is separated by a space, and the lines in ascending alphabetical order, note that the output letter to uppercase and shelf; Conversely, if the corresponding cannot be achieved, in the first line of the file shelf output is none. There are no extra spaces at the end of the line.

Sample Input

46 22 10 204 18 6 168 20 2 1810 24 4 89 1519 1711 721 11

Sample Output

A 4 B 1C 2D 3

1#include <iostream>2#include <cstdio>3#include <cstring>4 using namespacestd;5 6 Const intmaxn= -;7 intN;8 structNode {9     intxmin;Ten     intXmax; One     intymin; A     intYmax; -     intx; -     inty; the }A[MAXN],B[MAXN]; -  - intY1[MAXN],X1[MAXN]; -  + BOOLBianjie (intXintYintX1,intX2,intY1,inty2) - { +     if(x>=x1&&x<=x2&&y>=y1&&y<=y2) A        return 1; at     return 0;  - } -  - intMain () - { -      while(cin>>N) in     { -          for(intI=1; i<=n;i++) to         { +Cin>>a[i].xmin>>a[i].xmax>>a[i].ymin>>A[i].ymax; -         } the          for(intI=1; i<=n;i++) *         { $Cin>>b[i].x>>b[i].y;Panax Notoginseng         } -             intm=N; thememset (x1,0,sizeof(x1)); +memset (Y1,0,sizeof(y1)); A             intCnt=0; the              while(m--) +             { -                  for(intI=1; i<=n;i++) $                 { $                     if(Y1[i])Continue; -                     intflag=0, temp;  -                      for(intj=1; j<=n;j++) the                     { -                         if(X1[j])Continue;Wuyi                         if(Bianjie (B[i].x,b[i].y,a[j].xmin,a[j].xmax,a[j].ymin,a[j].ymax)) the                         { -temp=J; Wuflag++; -                         } About                     } $                     if(flag==1) -                     { -x1[temp]=i; -y1[i]=temp; Acnt++; +                     } the                 } -             } $             if(cnt!=N) the             { thecout<<"None"<<Endl; the                 Continue; the             } -              for(intI=1; i<=n;i++) incout<<Char(i+ -) <<" "<<x1[i]<<Endl; the     } the     return 0; About}

Topological sorting-annoying slides

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.