匈牙利算法模板题 有n门课程,每门课程可能有不同一时候间,不同一时候间的课程等价. 问不冲突的情况下最多能选多少门课. 建立二分图,一边顶点表示不同课程,还有一边表示课程的时间(hash一下). #include <iostream> #include <cstring> #include <string> #include <cstdio> #include <cmath> #include <algorithm> #include…
题目地址:http://poj.org/problem?id=2239 Li Ming大学选课,每天12节课,每周7天,每种同样的课可能有多节分布在不同天的不同节.问Li Ming最多可以选多少节课.把n种课划分为X集合,把一周的84节课划分为Y集合, 从Xi向Yi连边,那么就转化成了求二分图的最大匹配数,然后匈牙利算法就可以了. #include<cstdio> #include<iostream> #include<string.h> #include<alg…
题目链接 N节课,每节课在一个星期中的某一节,求最多能选几节课 好吧,想了半天没想出来,最后看了题解是二分图最大匹配,好弱 建图: 每节课 与 时间有一条边 #include <iostream> #include <cstdio> #include <cmath> #include <cstring> #include <algorithm> #include <vector> using namespace std; + ; in…
解题报告 http://blog.csdn.net/juncoder/article/details/38154699 题目传送门 题意: 每天有12节课.一周上7天,一门课在一周有多天上课. 求一周最多上几节课. 思路: 把课程看成一个集合,上课的时间看成一个集合,二分图就出来了. #include <cstdio> #include <cstring> #include <iostream> using namespace std; int n,day[10][15…
http://poj.org/problem?id=1469 这道题我绝壁写过但是以前没有mark过二分图最大匹配的代码mark一下. 匈牙利 O(mn) #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #include<iostream> #include<queue> using namespace std; #define LL lon…
Selecting Courses Time Limit: 1000MS   Memory Limit: 65536K       Description It 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 eve…
题目链接:https://cn.vjudge.net/problem/HDU-1083 题意 有一些学生,有一些课程 给出哪些学生可以学哪些课程,每个学生可以选多课,但只能做一个课程的代表 问所有课能否全部都有代表? 思路 二分图最大匹配问题 一个学生只能匹配一个课程,那么X部是学生,Y部是课程 求最大匹配即可 注意 二分图复杂度O(E*V) 邻接矩阵里G[a][b], a属于X部,b属于Y部,这是俩图所以ab节点的id可以相同 初始化match和vis 提交过程 AC 模版题 代码 #incl…
主题链接: http://poj.org/problem?id=2239 题目大意: 学校总共同拥有N门课程,而且学校规定每天上12节可,一周上7天. 给你每门课每周上的次数,和哪一天哪一节 课上的.假设有多门课程在同一天同一节课上.那么你仅仅能选择当中一门.那么问题来了:最多能同一时候选多少 门课而不发生冲突呢. 输入说明: 先给你一个N.表示有N门课.接下来N行,每行第一个数字x,表示这门课每周上几节.接下来是x对数.第 一个数D表示是这一周哪一天上的,第二个数C表示是这一天哪一节课上的.…
题目链接:https://vjudge.net/problem/HDU-1083 Courses Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8869    Accepted Submission(s): 4319 Problem Description Consider a group of N students and P c…
1.poj 2239   Selecting Courses   二分图最大匹配问题 2.总结:看到一个题解,直接用三维数组做的,很巧妙,很暴力.. 题意:N种课,给出时间,每种课在星期几的第几节课上,求最多可上几种课. #include<iostream> #include<cstring> #include<cstdio> using namespace std; ][][]; ][],pipei[][]; int findn(int n) { ;i<=;i+…