![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
图论
文章平均质量分 75
dominating大树置林
l love acm!
展开
-
poj 1094 Sorting It All Out
题意:n个数m组比较,判断三种情况:有环,有序,无序;思路:拓扑排序。初始时度数为0的点数大于1时,无序;度为0个数等于1时,有序;不存在度为0的数时,无序;#include#include#includeusing namespace std;int n,m;int mm[505][505],hh;int q[500010],indegree[500010];int top原创 2015-03-14 21:18:12 · 284 阅读 · 0 评论 -
hdu 1285 确定比赛名次
题意:给出每两个队伍的胜负关系,求排名。思路:裸裸的拓扑排序。#include#include#includeusing namespace std;int n,m,p1,p2;int indegree[500010],match[505][505],flag;void tuopu(){ int i,j,k,flag=0; for(j=1;j<=n;j++)原创 2015-03-13 14:18:52 · 513 阅读 · 0 评论 -
hdu 2094 产生冠军
题意:给出n对选手姓名,每对表示前者赢后者,求整场比赛是否有冠军;思路:将名字用数字表示,离散化,然后就是裸裸的拓扑排序,只需判断初始时入度为0的是否唯一;#include#include#includeusing namespace std;int n,m,i,j,k,con;int mm[1001][1001],indegree[500010];char s1[500010原创 2015-03-13 20:48:00 · 510 阅读 · 0 评论 -
hdu 3342 Legal or Not
题意:判断有无环路;思路:拓扑排序;两种写法:结构体+指针:#include#include#includeusing namespace std;int n,m;struct node{ int du; node *next;}q[50010];int topo(){ node *p; int *shu=new int[50010]原创 2015-03-14 15:41:46 · 485 阅读 · 0 评论 -
hdu 2647 Reward
题意:给出n对员工需求,每队包含两个员工编号,要求前者奖金大于后者,求所有员工的奖金数;思路:拓扑排序判定有无环;#include#include#includeusing namespace std;int n,m;struct node{ int du; node *next;}q[500010];int topo(){ int i,j,k原创 2015-03-14 13:54:29 · 586 阅读 · 0 评论