poj——2239   Selecting Courses Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10656   Accepted: 4814 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 c…
Selecting Courses Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8316   Accepted: 3687 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 Mi…
题目地址: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…
http://poj.org/problem?id=2239 这里要处理的是构图问题p (1 <= p <= 7), q (1 <= q <= 12)分别表示第i门课在一周的第p天的第q节课上 其中二分图的X集合里表示课程i,那么我们要解决的就是Y集合了 将第i门课在一周的第p天的第q节课上进行编号,这样Y集合就是 上课时间的编号了 #include<stdio.h> #include<string.h> #include<math.h> #in…
二分图的最大匹配.课程和时间可以看做二分图. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; ; int nx,ny; int g[MAXN][MAXN]; int cx[MAXN],cy[MAXN]; int mk[MAXN]; int n; ]; int path(int u) { ; v<ny; v++) { i…
1.poj 2239   Selecting Courses   二分图最大匹配问题 2.总结:看到一个题解,直接用三维数组做的,很巧妙,很暴力.. 题意:N种课,给出时间,每种课在星期几的第几节课上,求最多可上几种课. #include<iostream> #include<cstring> #include<cstdio> using namespace std; ][][]; ][],pipei[][]; int findn(int n) { ;i<=;i+…
Selecting Courses Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9380   Accepted: 4177 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 Mi…
题目链接:pid=3697" target="_blank">http://acm.hdu.edu.cn/showproblem.php?pid=3697 Problem Description     A new Semester is coming and students are troubling for selecting courses. Students select their course on the web course system. There…
Description     A new Semester is coming and students are troubling for selecting courses. Students select their course on the web course system. There are n courses, the ith course is available during the time interval (A i,B i). That means, if you…
Description     A new Semester is coming and students are troubling for selecting courses. Students select their course on the web course system. There are n courses, the ith course is available during the time interval (Ai,Bi). That means, if you wa…
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…
Selecting courses Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 62768/32768 K (Java/Others) Total Submission(s): 2082    Accepted Submission(s): 543 Problem Description     A new Semester is coming and students are troubling for selecting c…
Selecting courses Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 62768/32768 K (Java/Others) Total Submission(s): 1856    Accepted Submission(s): 469 Problem Description     A new Semester is coming and students are troubling for selecting c…
呃呃呃呃呃 把每个课给了INF个容量....我是沙雕把....emm....这题就是做着玩...呃呃呃别当真.... #include <iostream> #include <cstdio> #include <sstream> #include <cstring> #include <map> #include <cctype> #include <set> #include <vector> #inclu…
主题链接: http://poj.org/problem?id=2239 题目大意: 学校总共同拥有N门课程,而且学校规定每天上12节可,一周上7天. 给你每门课每周上的次数,和哪一天哪一节 课上的.假设有多门课程在同一天同一节课上.那么你仅仅能选择当中一门.那么问题来了:最多能同一时候选多少 门课而不发生冲突呢. 输入说明: 先给你一个N.表示有N门课.接下来N行,每行第一个数字x,表示这门课每周上几节.接下来是x对数.第 一个数D表示是这一周哪一天上的,第二个数C表示是这一天哪一节课上的.…
题目链接 N节课,每节课在一个星期中的某一节,求最多能选几节课 好吧,想了半天没想出来,最后看了题解是二分图最大匹配,好弱 建图: 每节课 与 时间有一条边 #include <iostream> #include <cstdio> #include <cmath> #include <cstring> #include <algorithm> #include <vector> using namespace std; + ; in…
匈牙利算法模板题 有n门课程,每门课程可能有不同一时候间,不同一时候间的课程等价. 问不冲突的情况下最多能选多少门课. 建立二分图,一边顶点表示不同课程,还有一边表示课程的时间(hash一下). #include <iostream> #include <cstring> #include <string> #include <cstdio> #include <cmath> #include <algorithm> #include…
题目链接:http://poj.org/problem?id=1469 COURSES Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 21229   Accepted: 8355 Description Consider a group of N students and P courses. Each student visits zero, one or more than one courses. Your tas…
http://poj.org/problem?id=1469 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24197   Accepted: 9428 Description Consider a group of N students and P courses. Each student visits zero, one or more than one courses. Your task is to deter…
题目链接:http://poj.org/problem?id=2446 给你一个n*m的棋盘,其中有k个洞,现在有1*2大小的纸片,纸片不能覆盖洞,并且每个格子最多只能被覆盖一次.问你除了洞口之外这个棋盘是否能被纸片填满. 这个题目一眼很难看出是二分图匹配... 可以根据i和j性质可以看出,i+j为奇数的上下相邻的i'和j'一定是偶数,那么一个1*2的纸片的i+j一定是一个奇数一个偶数.所以我是建立一个二分图两个集合,将i+j为奇数的点与上下左右相邻的点连在一起,当然点不是洞.最后就用匈牙利算法…
http://poj.org/problem?id=3041 Asteroids Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12601   Accepted: 6849 Description Bessie wants to navigate her spaceship through a dangerous asteroid field in the shape of an N x N grid (1 <= N <…
题目链接:http://poj.org/problem?id=1698 思路:最大匹配容易想到,关键是如何建图,这里我们可以将电影按需要的天数进行拆点,然后对于可以选择的日子连边,最后只需判断最大匹配数是否等于总天数. http://paste.ubuntu.com/5939771/…
http://poj.org/problem?id=3041 在n*n的网格中有K颗小行星,小行星i的位置是(Ri,Ci),现在有一个强有力的武器能够用一发光速将一整行或一整列的小行星轰为灰烬,想要利用这个武器摧毁所有的小行星最少需要几发光束. 主要是构图,将每一行当成一个点,构成集合1,每一列也当成一个点,构成集合2,每一个障碍物的位置坐标将集合1和集合2的点连接起来,也就是将每一个障碍物作为连接节点的边,这样可以得出本题是一个最小点覆盖的问题==二分图的最大匹配. 就可以通过匈牙利算法求解.…
学习网络流中ing...作为初学者练习是不可少的~~~构图方法因为书上很详细了,所以就简单说一说 把光束作为图的顶点,小行星当做连接顶点的边,建图,由于 最小顶点覆盖 等于 二分图最大匹配 ,因此求二分图最大匹配即可. 邻接矩阵,DFS寻找增广路,匈牙利算法 邻接矩阵:复杂度O(n^3) 如果使用邻接表:复杂度O(n*m) #include<cstdio> #include<cstring> #include<cmath> #include<iostream>…
题意: 一个学生要选课,给出一系列课程的可选时间(按分钟计),在同一时刻只能选一门课程(精确的),每隔5分钟才能选一次课,也就是说,从你第一次开始选课起,每过5分钟,要么选课,要么不选,不能隔6分钟再选.在给出的课程的事件Ai~Bi内,Bi起的那分钟是不能够选的了,就是说截止到(Bi-1)分钟59秒还能选,Bi就不能选了. 思路: 由于n最大才300,那就可以使用暴力解法.开始时刻可以从0~4分钟这5个时刻开始,因为每5分钟是个周期,比如0分没选,而5分才选了,这和从5分才开始选是一样的.每隔5…
思路:最大匹配 也是很裸的一道题-. // by SiriusRen #include <cstdio> #include <cstring> #include <algorithm> using namespace std; #define N 500 int n,tot=0,first[N],v[N*N],next[N*N],jy,xx,yy,ans=0,vis[N],fa[N]; void add(int x,int y){v[tot]=y,next[tot]=f…
CoursesTime Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 10769    Accepted Submission(s): 5077 Problem DescriptionConsider a group of N students and P courses. Each student visits zero, one or m…
COURSES Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 19458   Accepted: 7658 Description Consider a group of N students and P courses. Each student visits zero, one or more than one courses. Your task is to determine whether it is poss…
题目链接:https://vjudge.net/problem/HDU-3697 题目大意:选课,给出每门课可以的选课时间.自开始选课开始每过五分钟可以选一门课,开始 时间必须小于等于四,问最多可以选多少门课. 题目分析:贪心即可. 先按照结束时间进行排序,然后枚举不同开始选课时间可以选到的课程数目, 输出最大的即可. (感觉这题题意好迷,怕是个题意题喲) 给出代码: #include <cstdio> #include <iostream> #include <string…
#include<iostream> #include<algorithm> #define MAXN 305 using namespace std; int _m[MAXN][MAXN]; ][]; int match[MAXN]; bool ck[MAXN]; bool search(int a,int b,int x) { int i; int t; ; i < b ; i++) if (_m[x][i] && ! ck[i]) { ck[i] = t…