Sorting Slides
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 4442   Accepted: 1757

Description

Professor Clumsey is going to give an important talk this afternoon. Unfortunately, he is not a very tidy person and has put all his transparencies on one big heap. Before giving the talk, he has to sort the slides. Being a kind of minimalist, he wants to do this with the minimum amount of work possible.

The situation is like this. The slides all have numbers written on them according to their order in the talk. Since the slides lie on each other and are transparent, one cannot see on which slide each number is written. 


Well, one cannot see on which slide a number is written, but one may deduce which numbers are written on which slides. If we label the slides which characters A, B, C, ... as in the figure above, it is obvious that D has number 3, B has number 1, C number 2
and A number 4.

Your task, should you choose to accept it, is to write a program that automates this process.

Input

The input consists of several heap descriptions. Each heap descriptions starts with a line containing a single integer n, the number of slides in the heap. The following n lines contain four integers xmin, xmax, ymin and ymax, each, the bounding coordinates
of the slides. The slides will be labeled as A, B, C, ... in the order of the input.

This is followed by n lines containing two integers each, the x- and y-coordinates of the n numbers printed on the slides. The first coordinate pair will be for number 1, the next pair for 2, etc. No number will lie on a slide boundary.

The input is terminated by a heap description starting with n = 0, which should not be processed. 

Output

For each heap description in the input first output its number. Then print a series of all the slides whose numbers can be uniquely determined from the input. Order the pairs by their letter identifier.

If no matchings can be determined from the input, just print the word none on a line by itself.

Output a blank line after each test case. 

Sample Input

  1. 4
  2. 6 22 10 20
  3. 4 18 6 16
  4. 8 20 2 18
  5. 10 24 4 8
  6. 9 15
  7. 19 17
  8. 11 7
  9. 21 11
  10. 2
  11. 0 2 0 2
  12. 0 2 0 2
  13. 1 1
  14. 1 1
  15. 0

Sample Output

  1. Heap 1
  2. (A,4) (B,1) (C,2) (D,3)
  3.  
  4. Heap 2
  5. none

Source

————————————————————————————————————

题目的意思是给出n个矩形,里面每个分配一个数字,问唯一的数字有哪几个

思路:二分图匹配关键边判定,先求二分图匹配,再枚举去掉已匹配的每一条边,判是否匹配数减少,若减少则为关键边

  1. #include <iostream>
  2. #include <cstdio>
  3. #include <string>
  4. #include <cstring>
  5. #include <cmath>
  6. #include <algorithm>
  7. #include <queue>
  8. #include <vector>
  9. #include <set>
  10. #include <stack>
  11. #include <map>
  12. #include <climits>
  13.  
  14. using namespace std;
  15.  
  16. #define LL long long
  17. const int INF = 0x3f3f3f3f;
  18.  
  19. const int MAXN=1000;
  20. int uN,vN; //u,v数目
  21. int g[MAXN][MAXN];//编号是0~n-1的
  22. int linker[MAXN];
  23. bool used[MAXN];
  24. int mat[MAXN];
  25. int aa[MAXN];
  26. struct area
  27. {
  28. int x1,x2,y1,y2;
  29. } s[100005];
  30. struct point
  31. {
  32. int x,y;
  33. } p[100005];
  34.  
  35. bool dfs(int u)
  36. {
  37. int v;
  38. for(v=0; v<vN; v++)
  39. if(g[u][v]&&!used[v])
  40. {
  41. used[v]=true;
  42. if(linker[v]==-1||dfs(linker[v]))
  43. {
  44. linker[v]=u;
  45. return true;
  46. }
  47. }
  48. return false;
  49. }
  50. int hungary()
  51. {
  52. int res=0;
  53. int u;
  54. memset(linker,-1,sizeof(linker));
  55. for(u=0; u<uN; u++)
  56. {
  57. memset(used,0,sizeof(used));
  58. if(dfs(u)) res++;
  59. }
  60. return res;
  61. }
  62.  
  63. int main()
  64. {
  65. int k,n;
  66. int cas=1;
  67. while(~scanf("%d",&n)&&n)
  68. {
  69. for(int i=0; i<n; i++)
  70. scanf("%d%d%d%d",&s[i].x1,&s[i].x2,&s[i].y1,&s[i].y2);
  71. for(int i=0; i<n; i++)
  72. scanf("%d%d",&p[i].x,&p[i].y);
  73. memset(g,0,sizeof g);
  74. for(int i=0; i<n; i++)
  75. for(int j=0; j<n; j++)
  76. {
  77. if(p[i].x>s[j].x1&&p[i].x<s[j].x2&&p[i].y>s[j].y1&&p[i].y<s[j].y2)
  78. g[i][j]=1;
  79. }
  80. uN=vN=n;
  81. int Match=hungary();
  82. printf("Heap %d\n",cas++);
  83.  
  84. if(Match<n)
  85. {
  86. printf("none\n");
  87. continue;
  88. }
  89. for(int i=0; i<n; i++)
  90. mat[i]=linker[i];
  91. int ct=0;
  92. for(int i=0; i<n; i++)
  93. {
  94. g[mat[i]][i]=0;
  95. if(hungary()<n)
  96. {
  97. aa[ct++]=i;
  98. }
  99. g[mat[i]][i]=1;
  100. }
  101. if(ct==0)
  102. printf("none\n");
  103. else
  104. {
  105. int q=0;
  106. for(int i=0; i<ct; i++)
  107. {
  108. if(q++)
  109. printf(" ");
  110. printf("(%c,%d)",'A'+aa[i],mat[aa[i]]+1);
  111. }
  112. printf("\n");
  113. }
  114. printf("\n");
  115. }
  116. return 0;
  117. }

  

POJ1468 Sorting Slides的更多相关文章

  1. POJ 1486 Sorting Slides (KM)

    Sorting Slides Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2831   Accepted: 1076 De ...

  2. 【POJ】1486:Sorting Slides【二分图关键边判定】

    Sorting Slides Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5390   Accepted: 2095 De ...

  3. poj1486 Sorting Slides

    Sorting Slides Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4812   Accepted: 1882 De ...

  4. poj 1486 Sorting Slides

    Sorting Slides Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4469   Accepted: 1766 De ...

  5. UVA663 Sorting Slides(烦人的幻灯片)

    UVA663 Sorting Slides(烦人的幻灯片) 第一次做到这么玄学的题,在<信息学奥赛一本通>拓扑排序一章找到这个习题(却发现标程都是错的),结果用二分图匹配做了出来 蒟蒻感觉 ...

  6. [ACM_图论] Sorting Slides(挑选幻灯片,二分匹配,中等)

    Description Professor Clumsey is going to give an important talk this afternoon. Unfortunately, he i ...

  7. poj 1486 Sorting Slides(二分图匹配的查找应用)

    Description Professor Clumsey is going to give an important talk this afternoon. Unfortunately, he i ...

  8. Sorting Slides(二分图匹配——确定唯一匹配边)

    题目描述: Professor Clumsey is going to give an important talk this afternoon. Unfortunately, he is not ...

  9. POJ 1486 Sorting Slides(寻找必须边)

    题意:找出幻灯片与编号唯一对应的情况 思路: 1:求最大匹配,若小于n,则答案为none,否则转2 (不过我代码没有事先判断一开始的最大匹配数是否<n,但这样也过了,估计给的数据最大匹配数一定为 ...

随机推荐

  1. js Map和Set

    Map Map是一组键值对的结构,具有极快的查找速度.JavaScript的对象有个小问题,就是键必须是字符串.但实际上Number或者其他数据类型作为键也是非常合理的.为了解决这个问题,最新的ES6 ...

  2. phpstorm+xdebug调试代码

    1工具 #phpstorm 前面有文章介绍如何安装 #phpStudy 官网下的2018最新的安装包,php环境使用的也是最新的php7.0nts 2开启php Xdebug拓展 开启拓展,phpSt ...

  3. MySql数据库 sql查询增加序号的伪列

    在查询数据库的时候,我们有时候需要对查询出来的数据加上序列,1,2,3,……n 例如:我们根据表的某个字段排序后,要对这些数据加上序列,这个时候序号常常不是我们建表时设置好的自增的主键id,怎么办呢? ...

  4. ActiveMq unsupported major.minor version 52.0

    网上是说ActiveMq已经编译好的版本和运行的java版本不一致导致的,看了一下MF文件 用的Jdk版本是1.8,而我们当前系统的java版本是1.7,所以尝试重新下载之前的ActiveMq的版本. ...

  5. 如何用xx-net上youtube

    1.下载https://github.com/XX-net/XX-Net/blob/master/code/default/download.md   里面的稳定版本 2.下载chrome.百度chr ...

  6. 2017/2/10:Manven简介与项目管理(入门)

    1.Maven工程的创建 2.使用Manven manven配置文件主要集中在 http://m.blog.csdn.net/article/details?id=50316383

  7. H.264, MPEG4之间的关系

    百度百科搜索 H.264 H.264是国际标准化组织(ISO)和国际电信联盟(ITU)共同提出的继MPEG4之后的新一代数字视频压缩格式.H.264是ITU-T以H.26x系列为名称命名的视频编解码技 ...

  8. springMVC 学习 五 参数传递(包括restful风格)

    (一)SpringMVC Controller接受参数的方式 (1) 前端传递的参数,在springMVC的controller中使用基本数据类型或者String 类型进行接受 在前端有一个form表 ...

  9. 2019.02.06 bzoj2187: fraction(类欧几里得)

    传送门 题意简述:多组询问,每次给出a,b,c,da,b,c,da,b,c,d,求满足ab<pq<cd\frac ab<\frac pq<\frac cdba​<qp​& ...

  10. 2018.11.06 NOIP训练 最大获利(profit)(01分数规划+最大权闭合子图)

    传送门 好题啊. ∑i<jpi,jK∗(200−K)>X\frac{\sum_{i<j}p_{i,j}}{K*(200-K)}>XK∗(200−K)∑i<j​pi,j​​ ...