POJ 1486 Sorting Slides (KM)】的更多相关文章

Sorting Slides Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2831   Accepted: 1076 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 transpa…
[题目链接] http://poj.org/problem?id=1486 [题目大意] 给出每张幻灯片的上下左右坐标,每张幻灯片的页码一定标在这张幻灯片上, 现在问你有没有办法唯一鉴别出一些幻灯片 [题解] 我们先求一遍匹配,然后对于匹配的边进行删去后再匹配, 如果匹配数量发生变化,则说明这条边不是完美匹配, 测试每一条边之后,我们就能得到完美匹配的边,就是答案. [代码] #include <cstdio> #include <cstring> using namespace…
题意:给你n张照片的范围,n个点的坐标,问你能唯一确定那几个点属于那几张照片,例如样例中4唯一属于A,2唯一属于C,1唯一属于B,3唯一属于C 思路:进行二分图完全匹配,怎么判断唯一属于?匹配完之后删掉某一条匹配边再跑一次二分图匹配,如果还能完全匹配,那么就不是唯一,反之唯一. 代码: #include<set> #include<map> #include<stack> #include<cmath> #include<queue> #incl…
Sorting Slides Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4469   Accepted: 1766 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 transpa…
題目鏈接 題意 :N个部门和N个员工,每个部门要雇佣一个工人,部门对每个工人打分,从1~N,1表示很想要,N表示特别不想要,每个工人对部门打分,从1~N.1表示很想去这个部门,N表示特别不想去这个部门,求一个匹配,使每个人的希望值最大. 思路 :KM算法.资料.用深搜构造所有能达到最大值的匹配情况.参考 #include <stdio.h> #include <string.h> #include <iostream> using namespace std ; ; i…
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 minima…
题意:找出幻灯片与编号唯一对应的情况 思路: 1:求最大匹配,若小于n,则答案为none,否则转2 (不过我代码没有事先判断一开始的最大匹配数是否<n,但这样也过了,估计给的数据最大匹配数一定为n吧) 2:删除一条边e,以e的一个端点找增广路,若不能找到增广路则e是必须边 也就是重新计算匹配数,如果匹配数减少说明此边是必须也是唯一的.    如果一样说明这边存不存在都行.转3 3:恢复原图,继续步骤2,直到每条边都被删除过 刚开始看网上别人的代码,有一点看不懂,那就是为什么只要找到唯一对应的就输…
题意 给你n个幻灯片,每个幻灯片有个数字编号1~n,现在给每个幻灯片用A~Z进行编号,在该幻灯片范围内的数字都可能是该幻灯片的数字编号.问有多少个幻灯片的数字和字母确定的. 思路 确定幻灯片的数字就是求完美匹配也就是最大匹配,而题目要求的边就是匹配的关键边,也叫必须边,即任意一个最大匹配一定要包含这条边. 关键边求法:先求一遍最大匹配,然后枚举删去匹配边,看之后的最大匹配是否减小,如果减小则该边是匹配关键边. 这让我想起了寻找关键割边:如果一个割边增加流量后整个最大流增加则该割边是关键割边.呵呵…
题目大意:有n张幻灯片和n个数字,幻灯片放置有重叠,每个数字隶属于一个幻灯片,现在问你能够确定多少数字一定属于某个幻灯片 思路:上次刷过二分图的必须点后这题思路就显然了 做一次二分匹配后将当前匹配的边删除,再做一次二分匹配,如果能匹配到那么说明这条边不是必须边 顺便说下 删边以后不用从头开始二分匹配,而是在原来二分匹配的基础上对这个点进行增广就行,另外这题格式需要注意,很容易PE #include<cstdio> #include<string.h> #include<ios…
UVA663 Sorting Slides(烦人的幻灯片) 第一次做到这么玄学的题,在<信息学奥赛一本通>拓扑排序一章找到这个习题(却发现标程都是错的),结果用二分图匹配做了出来 蒟蒻感觉思路不太好想,难度大概在蓝题~紫题,至于为什么是黑题.. 那是因为UVa输出换行空格万年老坑 #include<cstdio> #include<cstring> using namespace std; #define N 27 int vis[N],match[N],ans[N],…
POJ 3669 Meteor Shower(流星雨) Time Limit: 1000MS    Memory Limit: 65536K Description 题目描述 Bessie hears that an extraordinary meteor shower is coming; reports say that these meteors will crash into earth and destroy anything they hit. Anxious for her sa…
POJ 3253 Fence Repair (优先队列) Farmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needsN (1 ≤ N ≤ 20,000) planks of wood, each having some integer lengthLi (1 ≤ Li ≤ 50,000) units. He the…
[POJ 3071] Football(DP) Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4350   Accepted: 2222 Description Consider a single-elimination football tournament involving 2n teams, denoted 1, 2, -, 2n. In each round of the tournament, all tea…
Poj 3613 Cow Relays (图论) 题目大意 给出一个无向图,T条边,给出N,S,E,求S到E经过N条边的最短路径长度 理论上讲就是给了有n条边限制的最短路 solution 最一开始想到是的去直接统计最短路经过了多少条边,结果,,, 还是太年轻了... 不过,看数据范围只有1000,那么floyd是首选 回顾Floyd算法流程,其中的i到j松弛操作是通过k完成的 那么松弛一次就利用一个k点,我现在要经过n条边,那么松弛n次即可 详细说就是更新一次之后,把f[i][j]拷贝到原来的…
D - Jungle Roads Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 1251 Description The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extr…
Primitive Roots http://poj.org/problem?id=1284 Time Limit: 1000MS   Memory Limit: 10000K       Description We say that integer x, 0 < x < p, is a primitive root modulo odd prime p if and only if the set { (xi mod p) | 1 <= i <= p-1 } is equal…
Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 25165   Accepted: 7751 Description The Department of National Defence (DND) wishes to connect several northern outposts by a wireless network. Two different communication technologies are t…
Tour Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others) Total Submission(s): 2549    Accepted Submission(s): 1257 Problem Description In the kingdom of Henryy, there are N (2 <= N <= 200) cities, with M (M <= 3000…
Description Assume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in the sea side. And any radar installation, locating on the coasting, can only cover d distance, s…
Curling 2.0 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12158   Accepted: 5125 Description On Planet MM-21, after their Olympic games this year, curling is getting popular. But the rules are somewhat different from ours. The game is…
各位读者,大家好. 因为算法和数据结构相关的知识都是在国外学的,所以有些词汇翻译的可能不准确,然后一些源代码的注释可能是英文的,如有给大家带来什么不方便,请见谅.今天我想写一下Heap相关的知识,从基本的结构到最后的一些常用functions. Heap 的数据结构其实可以看成Array, 例如a[] = {5,3,6,8,2,1,0}这个数组, 我们可以将其看作如下的结构: Heap又可以分成2种类型:Max-Heap 和 Min-Heap. Max-Heap的意思是每一个node的key值都…
Description We have received an order from Pizoor Communications Inc. for a special communication system. The system consists of several devices. For each device, we are free to choose from several manufacturers. Same devices from two manufacturers d…
Description Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concatenation as multiplication, exponentiation by a non-negative inte…
https://vjudge.net/problem/POJ-1019 题意 给一串1 12 123 1234 12345 123456 1234567 12345678 123456789 12345678910 1234567891011这种形式的串,问这个串的第i个位置的数字是什么. 分析 这道题的重点在于到第k组时应该为几位数,即对于某个数x,它应该为几位数.答案是log10(x)+1.这样剩下的便是打表预处理了,找出每组的起始位置,再处理出一个最长的组. #include<iostre…
Linear world Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 4426   Accepted: 1006 Description The Disc, being flat, has no real horizon. Any adventurous sailors who get funny ideas from staring at eggs and oranges for too long and set o…
题目链接 Description Farmer John has built a new long barn, with N (2 <= N <= 100,000) stalls. The stalls are located along a straight line at positions x1,...,xN (0 <= xi <= 1,000,000,000). His C (2 <= C <= N) cows don't like this barn layo…
Description Dearboy, a goods victualer, now comes to a big problem, and he needs your help. In his sale area there are N shopkeepers (marked from 1 to N) which stocks goods from him.Dearboy has M supply places (marked from 1 to M), each provides K di…
Description Let N be the set of all natural numbers {0 , 1 , 2 , . . . }, and R be the set of all real numbers. wi, hi for i = 1 . . . n are some elements in N, and w0 = 0.  Define set B = {< x, y > | x, y ∈ R and there exists an index i > 0 such…
Description Andy is fond of old computers. He loves everything about them and he uses emulators of old operating systems on his modern computer. Andy also likes writing programs for them. Recently he has decided to write a text editor for his favorit…
Description A plotter is a vector graphics printing device that connects to a computer to print graphical plots. There are two types of plotters: pen plotters and electrostatic plotters. Pen plotters print by moving a pen across the surface of a piec…