POJ 1094 (传递闭包 + 拓扑排序)】的更多相关文章

http://poj.org/problem?id=1094 题意:给你m个字母,有n个判断语句.求在哪个语句就可以判断出这个是不是一个环,或者在哪个语句可以判断出这些字母的排序规则,或者就是不能确定. 思路:每输入一次,进行一次排序,看会不会构成环或者已经可以确定了判断规则. #include <stdio.h> #include <string.h> ]; ]; ][]; int topsort(int n) { ,tmp[],l=; ;i<n;i++) tmp[i]=i…
题意 给出n,代表有以A开始的n个字母,给出它们的m个小于关系(A<B).如果前i个关系可以确定n个字母的一个顺序就输出: Sorted sequence determined after i relations: 排好的字母. 如果前i个关系开始导致矛盾,就输出: Inconsistency found after i relations. m个关系后还不能确定顺序就输出: Sorted sequence cannot be determined. 代码 /* g[i][j]为邻接矩阵,e[i…
题目链接: POJ 1094 题目大意:有 1 ~ N 个大写字母,且从 A 开始依次 N 个.再给你 M 个小于的关系,比如 A < B ,让你判断三种可能: 1.在第 i 个关系罗列之后,是否可以满足使得这 N 个字母能递增关系. 2.在第 i 个罗列之后,是否会出现矛盾,例如 A > B,而在第 i 个状态出现后,B > A ,故矛盾. 3.如果 M 个条件罗列完后都没有出现矛盾,且还无法判断 N 个字母的排列顺序,则输出  Sorted sequence cannot be de…
题目链接:http://poj.org/problem?id=2367 题意: 知道一个数n, 然后n行,编号1到n, 每行输入几个数,该行的编号排在这几个数前面,输出一种符合要求的编号名次排序. 拓扑排序: 先找入度为0的点,再根据这个点删掉与之相连的点之间的弧,入度减一. #include <stdio.h> ][]; ]; int main() { int n; scanf("%d",&n); ;i<=n;i++) { int to; while(sca…
题目链接:http://poj.org/problem?id=1270 思路:就是一简单的dfs+拓扑排序,然后就是按字典序输出所有的情况. http://paste.ubuntu.com/5987294/…
Priest John's Busiest Day Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 11127   Accepted: 3785   Special Judge Description John is the only priest in his town. September 1st is the John's busiest day in a year because there is an old l…
poj 1094 Sorting It All Out Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%lld & %llu Description An ascending sorted sequence of distinct values is one in which some form of a less-than operator is used to order the elements from sm…
http://poj.org/problem?id=1094 Sorting It All Out Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24505   Accepted: 8487 Description An ascending sorted sequence of distinct values is one in which some form of a less-than operator is use…
Description An ascending sorted sequence of distinct values is one in which some form of a less-than operator is used to order the elements from smallest to largest. For example, the sorted sequence A, B, C, D implies that A < B, B < C and C < D.…
http://poj.org/problem?id=1094 原来拓扑序可以这样做,原来一直sb的用白书上说的dfs............ 拓扑序只要每次将入度为0的点加入栈,然后每次拓展维护入度即可.. 我是个大sb,这种水题调了一早上.. #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iostream> #include &…