tarjan
文章平均质量分 62
tomjobs
别慌,慌也没用
展开
-
LeetCode 207. 课程表(判断有向图是否有环)
你这个学期必须选修 numCourses 门课程,记为 0 到 numCourses - 1 。在选修某些课程之前需要一些先修课程。 先修课程按数组 prerequisites 给出,其中 prerequisites[i] = [ai, bi] ,表示如果要学习课程 ai 则 必须 先学习课程 bi 。例如,先修课程对 [0, 1] 表示:想要学习课程 0 ,你需要先完成课程 1 。请你判断是否可能完成所有课程的学习?如果可以,返回 true ;否则,返回 false 。示例 1:输入:numC原创 2021-03-14 20:06:18 · 373 阅读 · 0 评论 -
2020小米网络赛第一场 D Router Mesh(点双连通分量)
题意:一个图,求出删掉每个点后得到的连通块数量。思路:算出每个点所在的点双连通分量数目vis[i]vis[i]vis[i],就可以得出这个点删掉后增加的连通块数目了。同时算出初始的连通块数目allallall,则删掉点iii的连通块数目为vis[i]+all−1vis[i]+all-1vis[i]+all−1。#include <cstdio>#include <cstring>#include <algorithm>#include <vector.原创 2020-11-08 18:16:19 · 187 阅读 · 0 评论 -
牛客国庆day8 BZOJ 4450. [Neerc2015]Cactus Jubilee(tarjan,求方案数)
链接:https://ac.nowcoder.com/acm/contest/7865/B来源:牛客网题目描述This is the 20-th Northeastern European Regional Contest (NEERC). Cactus problems had become a NEERC tradition. The first Cactus problem was given in 2005, so there is a jubilee — 10 years of Cactus原创 2020-10-12 21:09:09 · 254 阅读 · 0 评论 -
Gym101612 Problem G. Grand Test(tarjan,low值应用)
题意:问图中是否存在两个点使得两个点存在至少三条不交叉路径,输出这三条路径。思路:被PC拉过来写,写了一个晚上还是不会XXX。最后参考了题解的写法:记录下每个点的次大low值和最大low值以及对应的点,由此回溯路径就可以保证不交叉了。本题实际就是找两个环拼在一起的情况。首先一开始的写法是在点双连通分量里面找到一个度数大于等于3的点,再从这个点出发找到另外一个度数大于等于3的点。因为点双连通分量里面的点一定在环上(排除孤立点),如果度数大于等于3那就说明在不止一个环上,那就一定存在至少三条路径。原创 2020-09-08 16:59:04 · 344 阅读 · 0 评论 -
Codeforces962F. Simple Cycles Edges(点双连通分量)
You are given an undirected graph, consisting of ???? vertices and ???? edges. The graph does not necessarily connected. Guaranteed, that the graph does not contain multiple edges (more than one edges between a pair of vertices) or loops (edges from a vert原创 2020-09-02 20:08:47 · 523 阅读 · 0 评论 -
ICPC NEAU Programming Contest 2020 K. 关键结点(最短路+割点)
题意:判断一个点在不在最短路上好办,就是从这个点到1的最短距离加上到n的最短距离加起来#include <cstdio>#include <cstring>#include <algorithm>#include <vector>#include <queue>#include <iostream>#include <map>#include <string>using namespace.原创 2020-06-07 15:03:49 · 327 阅读 · 0 评论 -
Ralph and Mushrooms CodeForces - 894E(tarjan缩点+dp)
Ralph is going to collect mushrooms in the Mushroom Forest.There are m directed paths connecting n trees in the Mushroom Forest. On each path grow some mushrooms. When Ralph passes a path, he collects all the mushrooms on the path. The Mushroom Forest has原创 2020-05-14 15:10:19 · 334 阅读 · 0 评论 -
ACWING 364. 网络(lca+tarjan求双连通分量缩点)
给定一张N个点M条边的无向连通图,然后执行Q次操作,每次向图中添加一条边,并且询问当前无向图中“桥”的数量。输入格式输入包含多组测试数据。每组测试数据,第一行包含两个整数N和M。接下来M行,每行包含两个整数A和B,表示点A和点B之间有一条边,点的编号为1~N。接下来一行,包含整数Q。在接下来Q行,每行包含两个整数A和B,表示在A和B之间加一条边。当输入0 0时表示输入终止。输出格式...原创 2019-09-17 18:03:04 · 228 阅读 · 0 评论 -
ACWING363. B城(tarjan求割点)
B城有 n 个城镇,m 条双向道路。每条道路连结两个不同的城镇,没有重复的道路,所有城镇连通。把城镇看作节点,把道路看作边,容易发现,整个城市构成了一个无向图。输入格式第一行包含两个整数 n 和 m。接下来m行,每行包含两个整数 a 和 b,表示城镇 a 和 b 之间存在一条道路。输出格式输出共n行,每行输出一个整数。第 i 行输出的整数表示把与节点 i 关联的所有边去掉以后(不去...原创 2019-09-17 17:56:59 · 294 阅读 · 0 评论 -
Electricity POJ - 2117(tarjan求割点)
Blackouts and Dark Nights (also known as ACM++) is a company that provides electricity. The company owns several power plants, each of them supplying a small area that surrounds it. This organization ...原创 2019-09-14 23:09:54 · 475 阅读 · 0 评论 -
Cycle HDU - 5215(判断奇数环和偶数环,边双连通分量)
Ery is interested in graph theory, today he ask BrotherK a problem about it: Given you a undirected graph with N vertexes and M edges, you can select a vertex as your starting point, then you need to ...原创 2019-09-06 11:19:51 · 1067 阅读 · 0 评论 -
The Cow Prom POJ - 3180(强连通分量)
The N (2 <= N <= 10,000) cows are so excited: it’s prom night! They are dressed in their finest gowns, complete with corsages and new shoes. They know that tonight they will each try to perform ...原创 2019-09-05 23:50:47 · 152 阅读 · 0 评论 -
Popular Cows POJ - 2186(tarjan缩点,模板)
Every 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, B) that tell...原创 2019-09-05 23:38:04 · 223 阅读 · 1 评论