
拓扑排序
拓扑排序
olamins_
退役acmer
展开
-
HDU6604 Blow up the city (灭绝树)
Blow up the cityTime Limit: 5000/5000 MS (Java/Others)Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 892Accepted Submission(s): 477Problem DescriptionCountry A and B are at war. Country A needs to organize transport teams ...原创 2020-07-31 21:45:33 · 238 阅读 · 0 评论 -
珂朵莉喊你一声大佬(Tarjan&拓扑序&卡常)
链接:https://ac.nowcoder.com/acm/problem/14524来源:牛客网时间限制:C/C++ 2秒,其他语言4秒空间限制:C/C++ 131072K,其他语言262144K64bit IO Format: %lld题目描述有n种大佬,第i种大佬有ai个珂朵莉想让最少个数的一种大佬的个数最多你可以创造m个任意种类的大佬,并且可以把一些大佬变成另一些大佬x -> y意味着可以把任意个x类型的大佬变成y类型的大佬一个大佬可以被转换多次对于每个y,最.原创 2020-07-25 21:47:29 · 935 阅读 · 0 评论 -
#ICPC 2019-2020 North-Western Russia Regional Contest E (拓扑排序)
E. Equidistanttime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputIn 2019 ICPC subregions structure was changed a little. Now for ea...原创 2019-11-27 21:06:34 · 929 阅读 · 0 评论 -
#HDU 4857 逃生 (拓扑排序 + 反向建图 + 原理)
逃生Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9657Accepted Submission(s): 2748Problem Description糟糕的事情发生啦,现在大家都忙着逃命。但是逃命的通道很窄,大...原创 2019-06-26 17:02:51 · 297 阅读 · 1 评论 -
#HDU 5695 Gym Class (拓扑排序)
Gym ClassTime Limit: 6000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2637Accepted Submission(s): 981Problem Description众所周知,度度熊喜欢各类体育活动。今天,它终于...原创 2019-06-26 16:13:45 · 143 阅读 · 0 评论 -
#HDU 1811 Rank of Tetris (拓扑排序 + 并查集)
Rank of TetrisTime Limit: 1000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 13306Accepted Submission(s): 3780Problem Description自从Lele开发了Rating系统...原创 2019-06-26 15:43:38 · 174 阅读 · 0 评论 -
#HDU 2647 Reward (拓扑排序 + 反向建图 )
RewardTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 14966Accepted Submission(s): 4795Problem DescriptionDandelion's uncle is a bo...原创 2019-06-25 23:22:39 · 177 阅读 · 0 评论 -
#POJ 3687 Labeling Balls (拓扑排序 + 反向建图 原理)
DescriptionWindy has N balls of distinct weights from 1 unit to N units. Now he tries to label them with 1 to N in such a way that:No two balls share the same label. The labeling satisfies severa...原创 2019-06-05 14:06:51 · 258 阅读 · 0 评论 -
#POJ 2762 Going from u to v or from v to u?(tarjan + 拓扑排序 + 链式前向星)
Going from u to v or from v to u?Time Limit: 2000MSMemory Limit: 65536KTotal Submissions: 20770为了让他们的儿子勇敢,嘉嘉和风把他们带到一个大山洞。这个洞穴有N个房间,还有连接一些房间的单向走廊。每次,风都会选择两个房间x和y,并要求他们的一个小儿子从一个房间到另一个房间。儿子可以从X到Y,也...原创 2019-06-03 22:07:19 · 200 阅读 · 0 评论 -
HDU 3342 Legal or Not
直接判断有无环就行,注意对邻接表初始化,不然就WA了#include<bits/stdc++.h>using namespace std;const int maxn = 1e5 + 5;vector <int> e[maxn << 1];int in[maxn], n, m, flag, X;void init() { memset...原创 2019-05-26 10:10:40 · 276 阅读 · 0 评论 -
HDU 2094 产生冠军 (拓扑排序思想)
本题虽然不需要拓扑排序,但是思想和拓扑排序是一样的,拓扑排序每次是弹出入度为0的点,且不能有环, 同样,这道题只要存在唯一的入度为0的点,就解决了下面是AC代码:#include<bits/stdc++.h>using namespace std;const int maxn = 1e5 + 5;int main(){ int n; while (c...原创 2019-05-26 09:48:27 · 241 阅读 · 0 评论 -
POJ 1285 确定比赛名词 (拓扑排序)
#include<bits/stdc++.h>using namespace std;const int maxn = 1e5 + 5;struct node{ int to, next;}e[maxn << 1];int head[maxn], in[maxn], n, m, cnt;void init() { memset(head, ...原创 2019-05-26 09:04:34 · 270 阅读 · 0 评论 -
#牛客网 拓扑排序 HNOI2015 菜肴制作
看题目第一眼以为是字典序,敲完发现并不是 QAQ, 正确写法应该是反着存,字典序按从大到小排就OK了,一般拓扑排序的题如果不是正常排的话可以尝试一下把图反过来画,这也是一种思路。下面是链式前向星的AC代码:#include<bits/stdc++.h>using namespace std;const int maxn = 1e5 + 5;struct node{...原创 2019-05-24 12:11:56 · 244 阅读 · 0 评论 -
#牛客网 [HAOI2016] 食物链 拓扑排序 + 邻接表 / 链式前向星 + dp
第一种 : 拓扑排序 + 链式前向星 + dp链式前向星不会的话看我这篇博客 :https://blog.youkuaiyun.com/weixin_43851525/article/details/90411677说一下里面的 dp[v] += dp[u], 这个要用到动态规划的思想,这一步的结果由上一步的来决定,我们想要确定一个有向图有多少个“食物链”, 可以确定每个出度为0的点(我把它称为“...原创 2019-05-23 22:24:16 · 302 阅读 · 0 评论