
图论
dominating大树置林
l love acm!
-
原创 poj 1094 Sorting It All Out
题意:n个数m组比较,判断三种情况:有环,有序,无序; 思路:拓扑排序。初始时度数为0的点数大于1时,无序;度为0个数等于1时,有序;不存在度为0的数时,无序; #include #include #include using namespace std; int n,m; int mm[505][505],hh; int q[500010],indegree[500010]; int top2015-03-14 21:18:12229
0
-
原创 hdu 1285 确定比赛名次
题意:给出每两个队伍的胜负关系,求排名。 思路:裸裸的拓扑排序。 #include #include #include using 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:52462
0
-
原创 hdu 2094 产生冠军
题意:给出n对选手姓名,每对表示前者赢后者,求整场比赛是否有冠军; 思路:将名字用数字表示,离散化,然后就是裸裸的拓扑排序,只需判断初始时入度为0的是否唯一; #include #include #include using namespace std; int n,m,i,j,k,con; int mm[1001][1001],indegree[500010]; char s1[5000102015-03-13 20:48:00464
0
-
原创 hdu 3342 Legal or Not
题意:判断有无环路; 思路:拓扑排序; 两种写法: 结构体+指针: #include #include #include using 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:46400
0
-
原创 hdu 2647 Reward
题意:给出n对员工需求,每队包含两个员工编号,要求前者奖金大于后者,求所有员工的奖金数; 思路:拓扑排序判定有无环; #include #include #include using namespace std; int n,m; struct node { int du; node *next; }q[500010]; int topo() { int i,j,k2015-03-14 13:54:29507
0