图论
__wwwwn
这个作者很懒,什么都没留下…
展开
-
畅通工程续 HDU - 1874 spfa&&链式前向星&&模板
某省自从实行了很多年的畅通工程计划后,终于修建了很多路。不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走的距离要短很多。这让行人很困扰。 现在,已知起点和终点,请你计算出要从起点到终点,最短需要行走多少距离。Input本题目包含多组数据,请处理到文件结束。 每组数据第一行包含两个正整数N和M(0<N<200,0<...原创 2019-02-18 16:19:25 · 119 阅读 · 0 评论 -
codeforces 1175E 倍增
题意:给你n个区间,m次询问覆盖[X,Y]至少要多少个区间题解:将p[x][j]定义为以x为开头的倍增1<<j个区间的右端点,剩下的直接求多少j就可以了#include <bits/stdc++.h>using namespace std;typedef long long ll;const int maxn = 1e6+10, INF = 0x3f3f3f...原创 2019-07-17 10:28:11 · 201 阅读 · 0 评论 -
How far away ? HDU - 2586 trajan算法lca
题意:树上查询两个点之间的距离题解:必须离线,res[i]=d[u]+d[v]-2*d[lca(u,v)];#include <bits/stdc++.h>using namespace std;typedef long long ll;const int maxn = 3e5+10, INF = 0x3f3f3f3f;#define mod 998244353#d...原创 2019-07-18 10:50:58 · 291 阅读 · 0 评论 -
华华和月月逛公园 tarjin求割边&&模板
链接:https://ac.nowcoder.com/acm/contest/392/I来源:牛客网题目描述月月和华华一起去逛公园了。公园很大,为了方便,可以抽象的看成一个N个点M条边的无向连通图(点是景点,边是道路)。公园唯一的入口在1号点,月月和华华要从这里出发,并打算参观所有的景点。因为他们感情很好,走多远都不会觉得无聊,所以所有景点和道路都可以无数次的重复经过。月月发现,有些...原创 2019-03-13 15:11:17 · 272 阅读 · 0 评论 -
Andrew and Taxi CodeForces - 1100E 二分+拓扑排序
Andrew prefers taxi to other means of transport, but recently most taxi drivers have been acting inappropriately. In order to earn more money, taxi drivers started to drive in circles. Roads in Andrew...原创 2019-03-03 16:51:48 · 374 阅读 · 0 评论 -
How Many Answers Are Wrong HDU - 3038 带权并查集&&向量偏移
TT and FF are ... friends. Uh... very very good friends -________-b FF is a bad boy, he is always wooing TT to play the following game with him. This is a very humdrum game. To begin with, TT should ...原创 2019-02-20 15:26:18 · 113 阅读 · 0 评论 -
食物链 POJ - 1182 带权并查集
动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种说法是"1 X Y",表示X和Y是同类。 第二种说法是"2 X Y",表示X吃Y。 此人对N个动物,用上述两种说法,一句接一句地说出K句话,...原创 2019-02-20 11:42:12 · 308 阅读 · 0 评论 -
J - Ant Trip HDU - 3018 欧拉回路&&并查集
Ant Country consist of N towns.There are M roads connecting the towns. Ant Tony,together with his friends,wants to go through every part of the country. They intend to visit every road , and every r...原创 2019-02-19 19:44:12 · 169 阅读 · 0 评论 -
hdu2852 KiKi's K-Number 树状数组+二分查找求第k大的数
For the k-th number, we all should be very familiar with it. Of course,to kiki it is also simple. Now Kiki meets a very similar problem, kiki wants to design a container, the container is to support t...原创 2019-01-21 15:53:41 · 224 阅读 · 0 评论 -
hdu2860 Regroup 简单并查集&&维护点权值
When ALPC42 got to a panzer brigade, He was asked to build software to help them regroup the battalions or companies. As the tradition of army, soldiers are rated according his or her abilities, taki...原创 2019-02-01 13:56:26 · 196 阅读 · 0 评论 -
hdu2868 Neighbor Friend floyd&&思维
Suppose we sort N persons in a line according to their heights,we are curious about the Neighbor Friend. A pair of Neighbor Friend is two person next to each other in the line,ignoring the order(ie (...原创 2019-02-01 14:54:15 · 423 阅读 · 0 评论 -
poj 2553 The Bottom of a Graph tarjan求强联通分量&&染色缩点&&模板
We 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 product V×V, i...原创 2019-02-02 16:39:06 · 148 阅读 · 0 评论 -
hdu 3023 Dirt 优先队列&&bfs&&启发思路
-- Hello, may I speak to Petrov, please? Hello, my darling... You know, there was a little accident at our home... No, no, don't worry, your computer was not damaged. It is only a bit dirty there now....原创 2019-02-06 09:59:46 · 237 阅读 · 0 评论 -
King of Destruction HDU - 3002 最小割&&模板
Zhou xingxing is the successor of one style of kung fu called "Karate Kid".he is falling love with a beautiful judo student,after being humiliated by her boyfriend,a Taekwando master from Japan,Zhou i...原创 2019-02-14 18:19:03 · 127 阅读 · 0 评论 -
Layout POJ - 3169 差分约束系统&&spfa最短路&&判负环
像其他人一样,奶牛在排队饲料时喜欢靠近他们的朋友。 FJ有N(2 <= N <= 1,000)个编号为1..N的奶牛从左到右按照编号从小到大站在一条直线上等待饲料。牛的数量与它们的编号相同,因为它们可能相当具有挑战性,所以有可能两头或多头奶牛可以在同一位置排队(也就是说,如果我们将每只奶牛看作是位于在数字线上的某个坐标上,那么两个或更多的母牛可以共享相同的坐标)。一些奶牛喜欢彼此,...原创 2019-02-19 11:13:31 · 214 阅读 · 0 评论 -
Intervals POJ - 1201 差分约束系统&&spfa最长路
You are given n closed, integer intervals [ai, bi] and n integers c1, ..., cn. Write a program that: reads the number of intervals, their end points and integers c1, ..., cn from the standard input,...原创 2019-02-18 21:12:29 · 144 阅读 · 0 评论 -
2019牛客暑期多校训练营(第四场) J 分层最短路
题意:在图上,有k次机会可以直接通过一条边,问起点与终点之间的最短路径。题解:模板题,分成k+1层,每一层往下连一条单向边讲解#include<bits/stdc++.h>using namespace std;typedef long long int ll;const int maxn= 1e3+5;const ll INF =1e18;struct edge...原创 2019-07-27 21:48:39 · 168 阅读 · 0 评论