图之拓扑排序
Nothing_227
Nothing is impossible!
展开
-
拓扑排序基本题目(一) OpenJ_Bailian - 4084
给出一个图的结构,输出其拓扑排序序列,要求在同等条件下,编号小的顶点在前。Input若干行整数,第一行有2个数,分别为顶点数v和弧数a,接下来有a行,每一行有2个数,分别是该条弧所关联的两个顶点编号。 v<=100, a<=500Output若干个空格隔开的顶点构成的序列(用小写字母)。Sample Input6 81 21 31 43 23 5...原创 2018-08-15 15:02:16 · 2139 阅读 · 0 评论 -
图之拓扑排序(二)HihoCoder - 1174,HihoCoder - 1175
题目较长请点击: HihoCoder - 1174 题目简介:判断所给的课程是否存在环;分析:以度为0的课程加入到队列中,然后依次查找后继,每次都将度减去1,然后将度为0 的课程继续加入到队列中。这样如果存在环的话,度就不可能为0,所以我们只需要统计入队列的元素和(cnt) 与 总课程数(n)的比较。如果(cnt < n),则存在环;否则反之!#include <...原创 2018-08-15 15:20:23 · 220 阅读 · 0 评论 -
Ordering task UVA 10305
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.InputThe input will consist of several...原创 2018-08-16 14:54:11 · 157 阅读 · 0 评论