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

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…
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…
#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…
..被多组测试坑了一波 #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> &…
/* 三维拓扑排序 将每个长方体分解成六个面,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进行比赛,比赛结束后,裁判委员会要将所有参赛队伍从前往后依次排名,但现在裁判委员会不能直…
有N个比赛队(1<=N<=500),编号依次为1,2,3,....,N进行比赛,比赛结束后,裁判委员会要将所有参赛队伍从前往后依次排名,但现在裁判委员会不能直接获得每个队的比赛成绩,只知道每场比赛的结果,即P1赢P2,用P1,P2表示,排名时P1在P2之前.现在请你编程序确定排名.  Input输入有若干组,每组中的第一行为二个数N(1<=N<=500),M:其中N表示队伍的个数,M表示接着有M行的输入数据.接下来的M行数据中,每行也有两个整数P1,P2表示即P1队赢了P2队. O…
http://acm.hdu.edu.cn/showproblem.php?pid=1285 #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <algorithm> #include <assert.h> #define IOS ios::sync_with_stdio(false) using namespace st…
Genealogical tree Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8003   Accepted: 5184   Special Judge Description The system of Martians' blood relations is confusing enough. Actually, Martians bud when they want and where they want. T…