Prince and Princess 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=4685 Description There are n princes and m princesses. Princess can marry any prince. But prince can only marry the princess they DO love. For all princes,give all the princesses tha…
Prince and Princess Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 2281    Accepted Submission(s): 677 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4685 Description: There are n princes and m…
Prince and Princess Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 1267    Accepted Submission(s): 358 Problem Description There are n princes and m princesses. Princess can marry any prince. B…
意甲冠军:今天,有n王子,m公主.现在给他们配对,与王子会嫁给一个男人,他喜欢.公主无法做出选择. 这标题去咬硬,还有一类似的题目poj1904.那个题目也是给王子与公主配对,但那个是王子公主各n个,且给定了一个完美匹配,然后求每一个王子能够做出的选择且不影响最大匹配数目.那题是先建各条喜欢关系的边.然后在由被选择的公主连一条边到与之配对的王子.强连通之后假设一个王子和一个公主在一个强连通分量中,那么他们结合的话,他们的还有一半也各自能在强连通中找到另外的匹配,就是符合题意的结果了. 这个题目算…
题意: 有n个王子和m个公主,每个王子都会喜欢若干个公主,也就是王子只跟自己喜欢的公主结婚,公主就比较悲惨, 跟谁结婚都行.然后输出王子可能的结婚对象,必须保证王子与任意这些对象中的一个结婚,都不会影响到剩余的王子的配对数,也就是不能让剩余的王子中突然有一个人没婚可结了. 思路: 对每个没有匹配的公主,建一个虚拟的王子,让他们变成匹配,然后由这个虚拟王子向每个公主建边.对每个没有匹配的王子,建一个虚拟的公主,让他们变成匹配,然后每个王子向这个虚拟公主建边.求一个Tarjan,判断是否为1个强连通…
Prince and Princess Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 150    Accepted Submission(s): 46 Problem Description There are n princes and m princesses. Princess can marry any prince. But…
Prince and Princess Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 2336    Accepted Submission(s): 695 Problem Description There are n princes and m princesses. Princess can marry any prince. B…
题目链接: http://bak.vjudge.net/problem/UVA-10635 Prince and Princess Time Limit: 3000MS 题意 给你两个数组,求他们的最长公共子串. 题解 每个数组的大小最大有62500,所以n^2的经典算法肯定行不通. 那么,我么就需要找突破口:这题和一般的最长公共子串问题有什么不同,题目告诉我们每个数字只出现一次.明显要在这上面做文章!由于每个数位子固定了,所以匹配是唯一的,(pos1,pos2)表示数x在a数组中的位置,在b数…
http://poj.org/problem?id=1904 Description Once upon a time there lived a king and he had N sons. And there were N beautiful girls in the kingdom and the king knew about each of his sons which of those girls he did like. The sons of the king were you…
题意经过一番转换变成了 让你在一个二分图上删一条边使得二分图的最大独立集大小至少+1 二分图的最大独立集=点数-最小点覆盖(最大匹配) 点数是固定不变的 所以我们要减少最大匹配数 则删掉的哪一条边必须是二分图匹配里必须的一条边 做法:先Dinic跑一次 然后Tarjan缩点 找到图中端点不为S/T且满流的边 再判两端点是否属于一个SCC 如果属于一个SCC则必定存在另一个边可以替换掉这条匹配边 #include<iostream> #include<cstdio> #include…