![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Tarjan
Tarjan
olamins_
退役acmer
展开
-
珂朵莉喊你一声大佬(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 · 886 阅读 · 0 评论 -
#牛客网 HAOI2006 受欢迎的牛
思路 : 首先用tarjan缩点,那么原图就成了DAG, 判定的条件为 新的DAG图如果只有一个点 (该点可能是孤立的也可能是几个)的出度为0, 那么就将这个点的原图 (可以说是他所包含的原点的集合)中的点的数目表示出来,但是如果出度为0的点个数大于1了,则不成立,直接输出0,因为这样的话就出现两个牛群(牛群可能是一只牛也可能是几只牛),那么就无法做到强连通。AC代码如下 :#inclu...原创 2019-05-29 22:39:43 · 146 阅读 · 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 · 157 阅读 · 0 评论 -
#HDU 2553 The Bottom of a Graph (强连通算法)
DescriptionWe will use the following (standard) definitions from graph theory. Let V be a nonempty and finite set, its elements being called vertices (or nodes). Let E be a subset of the Cartesian p...原创 2019-06-06 19:51:28 · 153 阅读 · 0 评论 -
#HDU 2186 Popular Cows
DescriptionEvery cow's dream is to become the most popular cow in the herd. In a herd of N (1 <= N <= 10,000) cows, you are given up to M (1 <= M <= 50,000) ordered pairs of the form (A,...原创 2019-06-06 22:09:11 · 107 阅读 · 0 评论 -
#POJ 3180 The Cow Prom (Tarjan 判环)
Total Submissions: 2954 Accepted: 1706 DescriptionThe N (2 <= N <= 10,000) cows are so excited: it's prom night! They are dressed in their finest gowns, complete with corsages and ne...原创 2019-06-07 13:37:42 · 138 阅读 · 0 评论 -
#POJ 3114 Countries in War (Tarjan + dijkstra )
Total Submissions: 5262 Accepted: 1529 DescriptionIn the year 2050, after different attempts of the UN to maintain peace in the world, the third world war broke out. The importance of indu...原创 2019-06-07 16:38:26 · 116 阅读 · 0 评论 -
#HDU 1269 迷宫城堡 (tarjan)
Problem Description为了训练小希的方向感,Gardon建立了一座大城堡,里面有N个房间(N<=10000)和M条通道(M<=100000),每个通道都是单向的,就是说若称某通道连通了A房间和B房间,只说明可以通过这个通道由A房间到达B房间,但并不说明通过它可以由B房间到达A房间。Gardon需要请你写个程序确认一下是否任意两个房间都是相互连通的,即:对于任意的i和...原创 2019-06-10 10:44:05 · 111 阅读 · 0 评论 -
#HDU 2767 (tarjan + 原理)
Problem DescriptionConsider the following exercise, found in a generic linear algebra textbook.Let A be an n × n matrix. Prove that the following statements are equivalent:1. A is invertible.2. A...原创 2019-06-11 15:17:23 · 168 阅读 · 0 评论 -
#HDU 1827 (tarjan + 简单原理)
Problem DescriptionTo see a World in a Grain of SandAnd a Heaven in a Wild Flower,Hold Infinity in the palm of your handAnd Eternity in an hour.—— William Blake听说lcy帮大家预定了新马泰7...原创 2019-06-11 16:57:48 · 106 阅读 · 0 评论 -
#牛客网 通知小弟 (tarjan + 思维)
在战争时期,A国派出了许多间谍到其他国家去收集情报。因为间谍需要隐秘自己的身份,所以他们之间只是单向联系。所以,某个间谍只能单向联系到一部分的间谍。同时,间谍也不知道跟他联系的是谁。HA是间谍们的老大,但他也只能联系到部分的间谍。HA现在有一项命令有告诉所有的间谍。HA想要知道他至少要告诉多少个他能联系上的间谍才能通知到所有的间谍。输入描述:有多个测试数据。对于每个测试数据:...原创 2019-06-13 16:35:51 · 334 阅读 · 0 评论 -
#POJ 1236 Network of Schools(Tarjan)
DescriptionA number of schools are connected to a computer network. Agreements have been developed among those schools: each school maintains a list of schools to which it distributes software (the ...原创 2019-06-17 23:03:58 · 109 阅读 · 0 评论 -
#POJ 1144 Network (割点)
A Telephone Line Company (TLC) is establishing a new telephone cable network. They are connecting several places numbered by integers from 1 to N . No two places have the same number. The lines are bi...原创 2019-06-19 10:33:14 · 115 阅读 · 0 评论 -
#HDU 4738 Caocao‘s Bridges(割边)巨坑!
Problem DescriptionCaocao was defeated by Zhuge Liang and Zhou Yu in the battle of Chibi. But he wouldn't give up. Caocao's army still was not good at water battles, so he came up with another idea....原创 2019-06-19 16:38:02 · 294 阅读 · 0 评论 -
#HDU 4635 Strongly connected (tarjan + 原理)
Problem DescriptionGive a simple directed graph with N nodes and M edges. Please tell me the maximum number of the edges you can add that the graph is still a simple directed graph. Also, after you ...原创 2019-06-20 11:09:12 · 162 阅读 · 0 评论 -
#POJ 3177 Redundant Paths (无向图缩点)
In order to get from one of the F (1 <= F <= 5,000) grazing fields (which are numbered 1..F) to another field, Bessie and the rest of the herd are forced to cross near the Tree of Rotten Apples....原创 2019-06-20 15:51:12 · 219 阅读 · 0 评论 -
POJ 3352 Road Construction(无向图缩点)
DescriptionIt's almost summer time, and that means that it's almost summer construction time! This year, the good people who are in charge of the roads on the tropical island paradise of Remote Isla...原创 2019-06-20 16:11:42 · 214 阅读 · 0 评论 -
#HDU 3836 Equivalent Sets (tarjan添加最少边强连通)
Equivalent SetsTime Limit: 12000/4000 MS (Java/Others)Memory Limit: 104857/104857 K (Java/Others)Total Submission(s): 6583Accepted Submission(s): 2374Problem DescriptionTo prove two s...原创 2019-06-21 10:32:45 · 130 阅读 · 0 评论 -
#牛客网 可达性 (tarjan)
题目描述给出一个 0 ≤ N ≤ 105 点数、0 ≤ M ≤ 105 边数的有向图,输出一个尽可能小的点集,使得从这些点出发能够到达任意一点,如果有多个这样的集合,输出这些集合升序排序后字典序最小的。输入描述:第一行为两个整数 1 ≤ n, m ≤ 105,接下来 M 行,每行两个整数 1 ≤ u, v ≤ 105 表示从点 u 至点 v 有一条有向边。数据保证没有重边...原创 2019-07-10 16:03:51 · 296 阅读 · 0 评论 -
#POJ 3694 Network (无向图缩点 + LCA)
NetworkTime Limit: 5000MS Memory Limit: 65536K Total Submissions: 14538 Accepted: 5260 DescriptionA network administrator manages a large network. The network consists of N com...原创 2019-08-31 16:33:20 · 193 阅读 · 0 评论 -
#POJ Knights of the Round Table (DFS二分染色 + 点双联通)
Knights of the Round TableTime Limit: 7000MS Memory Limit: 65536K Total Submissions: 16039 Accepted: 5315 DescriptionBeing a knight is a very attractive career: searching for t...原创 2019-09-17 00:24:20 · 268 阅读 · 0 评论 -
#洛谷 P3119 [USACO15JAN]草鉴定Grass Cownoisseur (tarjan + spfa最长路 / 分层图最长路)
收起 题目描述In an effort to better manage the grazing patterns of his cows, Farmer John has installed one-way cow paths all over his farm. The farm consists of N fields, conveniently numbered 1..N, wit...原创 2019-09-19 10:15:10 · 352 阅读 · 3 评论 -
#洛谷 P3469 [POI2008]BLO-Blockade (tarjan)
展开 题目描述There are exactly nnn towns in Byteotia.Some towns are connected by bidirectional roads.There are no crossroads outside towns, though there may be bridges, tunnels and flyovers. Each pa...原创 2019-10-07 00:16:55 · 291 阅读 · 0 评论 -
#HDU 3639 Hawk-and-Chicken (tarjan + 反向建边 + dp)
Hawk-and-ChickenTime Limit: 6000/2000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5031Accepted Submission(s): 1530Problem DescriptionKids in kinderga...原创 2019-10-13 22:34:34 · 279 阅读 · 1 评论 -
#HDU 2242 考研路茫茫——空调教室 (tarjan + dp + 处理重边)
考研路茫茫——空调教室Time Limit: 4000/2000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4867Accepted Submission(s): 1474Problem Description众所周知,HDU的考研教室是没有空调的,于...原创 2019-10-14 17:37:06 · 353 阅读 · 0 评论 -
#HDU By Recognizing These Guys, We Find Social Networks Useful (割边 + 链式前向星)
By Recognizing These Guys, We Find Social Networks UsefulTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 125536/65536 K (Java/Others)Total Submission(s): 4200Accepted Submission(s): 108...原创 2019-10-16 00:00:05 · 354 阅读 · 0 评论 -
#HDU 4612 Warm up (tarjan + 树的直径)
Warm upTime Limit: 10000/5000 MS (Java/Others)Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 10317Accepted Submission(s): 2380Problem Description N planets are connect...原创 2019-10-28 01:24:13 · 340 阅读 · 0 评论 -
Codeforces Round #447 (Div. 2) E (tarjan + dp)
Ralph is going to collect mushrooms in the Mushroom Forest.There aremdirected paths connectingntrees in the Mushroom Forest. On each path grow some mushrooms. When Ralph passes a path, he collec...原创 2020-02-03 11:33:59 · 403 阅读 · 0 评论 -
Codeforces Round #364 (Div. 2) F. Break Up(tarjan+暴力)
F. Break Uptime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAgain, there are hard times in Berland! Many towns have such tensions that even civil war is possible.There arentowns in ..原创 2020-06-27 10:06:54 · 214 阅读 · 0 评论