![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
拓扑排序
追风者_
要我自我介绍,挺秃然的
展开
-
【HDU 5961】 传递 bitset爆破 或 拓扑排序
传送门思路:一开始看到6s,直接用多源最短路看是否每两点距离都是1(若有路径),但是还是T飞了。后来学到bitset的方法,属实不错。这里讲一下自己的理解。我们把这个联通的概念再深入理解一下。如果1->2,表示1到2有一条边,那要满足题目限制条件的话,2连向的所有边,1都应该连过去!。如2->3, 2->4, 2->5 有边,那也一定要有1->3, 1->4 , 1->5 。到此,我们就可以引出bitset了。用二进制串表示当前这个结点和其他点的连接原创 2020-09-14 14:16:43 · 179 阅读 · 1 评论 -
【BAPC 2016】 C. Brexit BFS(拓扑排序)
A long time ago in a galaxy far, far away, there was a large interstellar trading union, consistingof many countries from all across the galaxy. Recently, one of the countries decided to leavethe union. As a result, other countries are thinking about lea原创 2020-07-23 16:54:14 · 213 阅读 · 0 评论 -
【AcWing 164】 可达性统计 拓扑排序 bitset优化
给定一张N个点M条边的有向无环图,分别统计从每个点出发能够到达的点的数量。输入格式第一行两个整数N,M,接下来M行每行两个整数x,y,表示从x到y的一条有向边。输出格式输出共N行,表示每个点能够到达的点的数量。数据范围1≤N,M≤30000输入样例:10 103 82 32 55 95 92 33 94 82 104 9输出样例:1633211111题意:如题思路:如果想到点了这个题就不是什么难题。首先,这是一张有向无环图,那么我们可以先拓扑一原创 2020-05-22 17:05:45 · 221 阅读 · 0 评论 -
【HDU 1285】 确定比赛名次 简单拓扑排序
Problem Description有N个比赛队(1<=N<=500),编号依次为1,2,3,。。。。,N进行比赛,比赛结束后,裁判委员会要将所有参赛队伍从前往后依次排名,但现在裁判委员会不能直接获得每个队的比赛成绩,只知道每场比赛的结果,即P1赢P2,用P1,P2表示,排名时P1在P2之前。现在请你编程序确定排名。Input输入有若干组,每组中的第一行为二个数N(1<=N<=500),M;其中N表示队伍的个数,M表示接着有M行的输入数据。接下来的M行数据中,每行也有两个整数原创 2020-05-18 19:57:16 · 146 阅读 · 0 评论 -
Northwestern Europe Regional Contest (NWERC) 2018 B. Kattis - brexitnegotiations 拓扑排序 贪心
As we all know, Brexit negotiations are on their way—but we still do not know whether they will actually finish in time.The negotiations will take place topic-by-topic. To organise the negotiations in the most effective way, the topics will all be discuss原创 2020-05-17 22:47:29 · 350 阅读 · 0 评论 -
【UVA 10305】 Ordering Tasks 拓扑排序模板题
John has n tasks to do. Unfortunately, the tasks are not independent and the execution of one task isonly possible if other tasks have already been executed.InputThe input will consist of several instances of the problem. Each instance begins with a lin原创 2020-05-17 20:19:41 · 231 阅读 · 0 评论