POJ 2771 最大独立集 匈牙利算法】的更多相关文章

(为什么最大独立集的背景都是严打搞对象的( _ _)ノ|壁) 思路:匈牙利算法 没什么可说的-- // by SiriusRen #include <cstdio> #include <cstring> using namespace std; int cases,n,tot,ans,first[555],next[555555],v[555555],fa[555],vis[555]; struct Student{int n;char sex[2],music[105],spor…
Asteroids Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 23963   Accepted: 12989 Description Bessie wants to navigate her spaceship through a dangerous asteroid field in the shape of an N x N grid (1 <= N <= 500). The grid contains K a…
http://poj.org/problem?id=3041 #include <cstdio> #include <cstring> #include <vector> using namespace std; int e[1004][1004]; bool vis[1004]; vector <int > G[1004]; int n,m; int dfs(int s){ vis[s]=true; if(s==n*2+1){//printf("…
http://poj.org/problem?id=1469 COURSES Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 19419   Accepted: 7642 Description Consider a group of N students and P courses. Each student visits zero, one or more than one courses. Your task is…
这道题又无耻的抄袭了别人的代码. 刚开始以为是最大匹配,把条件不相符的人连一起,然后求最大匹配,感觉麻烦,然后看了别人的解题报告,是把相符的人连一起,然后减去,其实就是最大独立集. 最大独立集=|G|-最大匹配. 首先先把性别分开,因为同性不能成为couple,然后把符合条件的异性连一起,然后就是最大匹配了. #include<stdio.h> #include<string.h> #define maxn 505 #define maxl 106 struct Person {…
emmmmm 让你敲个匈牙利 #include<cstdio> #include<algorithm> #include<cstring> #define N 510 using namespace std; int adj[N][N],n,k,vis[N],bf[N],cnt; int find(int x) { ;i<=n;i++) if (adj[x][i] && !vis[i]) { vis[i]=; if (!bf[i] || find(…
题目链接:http://poj.org/problem?id=1466 Girls and Boys Time Limit: 5000MS   Memory Limit: 10000K Total Submissions: 12026   Accepted: 5355 Description In the second year of the university somebody started a study on the romantic relations between the stu…
题目链接: http://poj.org/problem?id=2771 Description Frank N. Stein is a very conservative high-school teacher. He wants to take some of his students on an excursion, but he is afraid that some of them might become couples. While you can never exclude th…
传送门:http://poj.org/problem?id=3041 Asteroids Time Limit: 1000MS Memory Limit: 65536K Description Bessie wants to navigate her spaceship through a dangerous asteroid field in the shape of an N x N grid (1 <= N <= 500). The grid contains K asteroids (…
http://poj.org/problem?id=3041 在n*n的网格中有K颗小行星,小行星i的位置是(Ri,Ci),现在有一个强有力的武器能够用一发光速将一整行或一整列的小行星轰为灰烬,想要利用这个武器摧毁所有的小行星最少需要几发光束. 主要是构图,将每一行当成一个点,构成集合1,每一列也当成一个点,构成集合2,每一个障碍物的位置坐标将集合1和集合2的点连接起来,也就是将每一个障碍物作为连接节点的边,这样可以得出本题是一个最小点覆盖的问题==二分图的最大匹配. 就可以通过匈牙利算法求解.…