二分匹配
天涯-沧海
acmer
展开
-
(最大独立集+拆点)洛谷 P6268 [SHOI2002]舞会
这题就是要找最大独立集,即两两都没有跳过舞的最大集合,所以只要把每个人拆成两个点,如果ab两个人跳过舞,就给a,b'和a',b连边,最后ans=n-最大匹配/2,这最大匹配我跑的hk,快当然快一些,不过我想就匈牙利算法应该就可以了特意写一下:因为没有指定性别,所以要拆点,把i拆分i和i’ 那么U=V-M (M是最大匹配,U最大独立集,V是顶点数)2U=2V-2M 所以 U=n-M'/2题目描述某学校要召开一个舞会。已知学校所有 nnn 名学生中,有些学生曾经互相跳过舞...原创 2020-07-07 23:09:43 · 292 阅读 · 0 评论 -
(二分图最大匹配) 洛谷 P2055 [ZJOI2009]假期的宿舍
这一看就是求最大匹配了,当然也可以用最大流左边是人,右边是床,某个人可以躺到某张床上,就给他们连边,然后如果没回家的人数+要到学校的外校人数=最多匹配,那说明床和人能分好具体点讲下如何建图吧1.学生中回家的人不要连任何边,因为他们都回家了,学校的哪张床都睡不了2.学生中留校的人和自己的床连边3.在认识的人中,外校人和留校学生的床连边,留校学生和自己认识的所有人的床连边题目描述学校放假了 · · · · · · 有些同学回家了,而有些同学则有以前的好朋友来探访,那么住宿就..原创 2020-07-04 18:33:58 · 140 阅读 · 0 评论 -
2019 南京icpc J. Spy
Over time, those coaches in BDN Collegiate Progranuning Contest split into two camps.The big danger is that, while optimists and pessimists battle it out, the environment of this area becomes ever mor...原创 2019-12-01 18:20:41 · 738 阅读 · 0 评论 -
2018 Petrozavodsk Winter Camp, Yandex Cup CFGym 102155C Block, Stock and Two Smoking Galaxy Notes
DescriptionI decided to start a new fancy project related to cryptocurrency, deep learning, self-driving cars and maybe mobile voice assistance (will decide that later). I already have a team consis...原创 2019-09-29 20:27:37 · 467 阅读 · 0 评论 -
HDU 2819 Swap
DescriptionGiven an N*N matrix with each entry equal to 0 or 1. You can swap any two rows or any two columns. Can you find a way to make all the diagonal entries equal to 1?InputThere are sev...原创 2019-09-18 22:16:44 · 89 阅读 · 0 评论 -
POJ 2239 Selecting Courses
DescriptionIt is well known that it is not easy to select courses in the college, for there is usually conflict among the time of the courses. Li Ming is a student who loves study every much, and at...原创 2019-09-18 20:52:27 · 77 阅读 · 0 评论 -
POJ 2446 Chessboard
Alice and Bob often play games on chessboard. One day, Alice draws a board with size M * N. She wants Bob to use a lot of cards with size 1 * 2 to cover the board. However, she thinks it too easy to b...原创 2019-09-18 18:45:15 · 194 阅读 · 0 评论 -
CodeForces 557D Vitaly and Cycle
DescriptionAfter Vitaly was expelled from the university, he became interested in the graph theory.Vitaly especially liked the cycles of an odd length in which each vertex occurs at most once.Vi...原创 2019-09-17 23:06:23 · 151 阅读 · 0 评论 -
The Preliminary Contest for ICPC Asia Shenyang 2019 C. Dawn-K's water
InputThe input consists of multiple test cases, each test case starts with a number nnn (1≤n≤1031 \le n \le 10^31≤n≤103) -- the number of types, and mmm (1≤m≤1041 \le m \le 10^41≤m≤104) -- the least...原创 2019-09-14 20:25:21 · 241 阅读 · 0 评论 -
POJ 1274 The Perfect Stall
DescriptionFarmer John completed his new barn just last week, complete with all the latest milking technology. Unfortunately, due to engineering problems, all the stalls in the new barn are differen...原创 2019-09-14 18:34:35 · 106 阅读 · 0 评论 -
HDU 5093 Battle ships
Problem DescriptionDear contestant, now you are an excellent navy commander, who is responsible of a tough mission currently.Your fleet unfortunately encountered an enemy fleet near the South Po...原创 2019-09-12 23:02:57 · 84 阅读 · 0 评论 -
POJ 2226 Muddy Fields
Description Rain has pummeled the cows' field, a rectangular grid of R rows and C columns (1 <= R <= 50, 1 <= C <= 50). While good for the grass, the rain makes some patches of bar...原创 2019-09-12 22:59:12 · 116 阅读 · 0 评论 -
CFGym 101485E Elementary Math
DescriptionEllen is teaching elementary math to her students and the time for the final exam has come. The exam consists of n questions. In each question the students have to add (+),subtract (−...原创 2019-09-12 21:33:02 · 142 阅读 · 0 评论