HDU1285(拓扑排序裸题】的更多相关文章

John has n tasks to do. Unfortunately, the tasks are not independent and the execution of one task is only possible if other tasks have already been executed. Input The input will consist of several instances of the problem. Each instance begins with…
http://poj.org/problem?id=2367 队列版 #include <stdio.h> #include <math.h> #include <string.h> #include <stdlib.h> #include <iostream> #include <sstream> #include <algorithm> #include <string> #include <queu…
..被多组测试坑了一波 #include<iostream> #include<vector> #include<queue> using namespace std; typedef long long ll; const int N = 1e3; vector<int>edge[N]; vector<int> ans; priority_queue<int, vector<int>, greater<int> &…
#include<iostream> #include<vector> #include<queue> using namespace std; typedef long long ll; ; int in[N],n,r; vector<int>ans; vector<int>edge[N]; priority_queue<int,vector<int>,greater<int> >priq; int main…
https://vjudge.net/problem/UVA-10305 目前没学dfs做法,用的队列做法,每次找到一个入度为零的点出队后更新其他点,再加入入度为零的点直到查找完毕,这个题目显然一定有解不必考虑无解的情况. #include<bits/stdc++.h> using namespace std; ]; ][]; int main() { int n,m,i,j,k; ; queue<int>q; memset(,sizeof(in)); memset(e,,size…
原题地址 这算是我个人AC的第一个拓扑排序题目吧. 题目解读 给出几组比赛的胜负情况.推断最后的排名.依据题意这就是一个明显的拓扑排序问题了. 注意 假设由于可能的排名有多种情况,这时要保证编号小的在前. 题目输入的数据可能有反复边 拓扑排序 首先统计每一个结点的入度. 将度为0的结点编号放入队列(此题放入优先队列中)中. 然后进行循环: 取出队头结点,视作边的起点. 然后"删除与该点相连的边".代码就是将这个图中的该边还有一个结点(即终点)的入度减一: 假设减一以后,终点的入度变为了…
确定比赛名次 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 23336    Accepted Submission(s): 9441 Problem Description 有N个比赛队(1<=N<=500),编号依次为1,2,3,....,N进行比赛,比赛结束后,裁判委员会要将所有参赛队伍从前往后依次排名,但现在裁判委员会不能直接…
http://acm.hdu.edu.cn/showproblem.php?pid=1285 题目大意: 给你每场比赛的成绩,让你根据成绩把排名弄出来 分析: 本来我是用普通方法写的,然后就一直wa,上网搜了一下是拓扑排序,我发现我从来没有写过拓扑排序 就问度娘吧没有办法了,然后度娘是这样跟我说的 对一个有向无环图(Directed Acyclic Graph简称DAG)G进行拓扑排序,是将G中所有顶点排成一个线性序列,使得图中任意一对顶点u和v,若边(u,v)∈E(G),则u在线性序列中出现在…
/* 三维拓扑排序 将每个长方体分解成六个面,xyz三维进行操作 每一维上的的所有长方体的面都应该服从拓扑关系,即能够完成拓扑排序=如果两个长方体的关系时相交,那么其对应的三对面只要交叉即可 如 a1 b1 a2 b2反之对应的那对面不可以交叉 如a1 a2 b1 b2 同时长方体自身的对应两个面也具有拓扑关系 */ #include<bits/stdc++.h> using namespace std; #define maxn 10005 ][maxn*]; ][maxn],tot[],]…
确定比赛名次 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 37566    Accepted Submission(s): 14659 Problem Description 有N个比赛队(1<=N<=500),编号依次为1,2,3,....,N进行比赛,比赛结束后,裁判委员会要将所有参赛队伍从前往后依次排名,但现在裁判委员会不能直…