POJ2239二分匹配】的更多相关文章

开始以为是最长路,想着把每一门课程的每一节课时作为一个点去建有向图...然后写的时候发现点太多了(300*7*12)建图特麻烦,就果断放弃了这个思路. 然后开始用排除法来想用什么算法合适,没环不可能缩点,源点汇点非常不明显不像最大流,什么最小生成树啊就更不可能了.那就是二分了,可是怎么分呢?我就想输出的是最多能上多少门课,答案肯定小于等于n(课程数目),给你了每门课程的所有时间,哎呀!用每门课程去匹配一个合适的时间不就完了吗?最大匹配数一定小于等于n. 上代码 #include<cstdio>…
题意: 就是尽可能的选多的课 思路: 把课程和上课的时间看作二分图 跑一跑二分匹配就好了 #include<iostream> #include<cstdio> #include<string.h> #include<algorithm> using namespace std; #define INF 0x3f3f3f3f #define N 350 int cos[10][20]; int ma[N][N]; bool vis[N]; int n; in…
题意:       一周有7天,每天可以上12节课,现在给你每科课的上课时间,问你一周最多可以上几科课,一科课只要上一节就行了. 思路:       简单题目,直接二分就行了,好久没写二分匹配了,练习下手而已. #include<stdio.h> #include<string.h> #define N_node 400 #define N_edge 27000 typedef struct {     int to ,next; }STAR; STAR E[N_edge]; in…
The Perfect Stall Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24081   Accepted: 10695 Description Farmer John completed his new barn just last week, complete with all the latest milking technology. Unfortunately, due to engineering p…
刚回到家 开了二分匹配专题 手握xyl模板 奋力写写写 终于写完了一群模板题 A hdu1045 对这个图进行 行列的重写 给每个位置赋予新的行列 使不能相互打到的位置 拥有不同的行与列 然后左行右列 边是新的坐标 求最大匹配 #include<stdio.h> #include<string.h> #include<algorithm> #include<math.h> #include<map> #include<string>…
1189: [HNOI2007]紧急疏散evacuate Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 1155  Solved: 420[Submit][Status][Discuss] Description 发生了火警,所有人员需要紧急疏散!假设每个房间是一个N M的矩形区域.每个格子如果是'.',那么表示这是一块空地:如果是'X',那么表示这是一面墙,如果是'D',那么表示这是一扇门,人们可以从这儿撤出房间.已知门一定在房间的边界上,并且…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5943 题意:给你两个数n, s 然后让你判断是否存在(s+1, s+2, s+3, ... , s+n )的任意排列方式使得每个数都满足当前数num,与num所在位置 pos  形成num%pos=0: 例如 n = 4 , s = 11 num = {13, 14, 15, 12} pos =  {1,    2,   3,    4} 每个num与之对应的pos都是num%pos = 0;的关系…
Taxi Cab Scheme Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 5710   Accepted: 2393 Description Running a taxi station is not all that simple. Apart from the obvious demand for a centralised coordination of the cabs in order to pick up…
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…
描述 农夫约翰上个星期刚刚建好了他的新牛棚,他使用了最新的挤奶技术.不幸的是,由于工程问题,每个牛栏都不一样.第一个星期,农夫约翰随便地让奶牛们进入牛栏,但是问题很快地显露出来:每头奶牛都只愿意在她们喜欢的那些牛栏中产奶.上个星期,农夫约翰刚刚收集到了奶牛们的爱好的信息(每头奶牛喜欢在哪些牛栏产奶).一个牛栏只能容纳一头奶牛,当然,一头奶牛只能在一个牛栏中产奶. 给出奶牛们的爱好的信息,计算最大分配方案. 格式 PROGRAM NAME: stall4 INPUT FORMAT: (file s…