![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
图论
青龙指引你
也并非所有的流浪者都迷失了自我
展开
-
Prim算法模板
Prim算法原创 2017-09-15 19:14:52 · 713 阅读 · 0 评论 -
PAT (Advanced Level) 1013. Battle Over Cities (25) DFS求连通分量
题目链接1013. Battle Over Cities (25)Time limit:400 ms Memory limit:65536 kBProblem DescrpitionIt is vitally important to have all the cities connected by highways in a war. If a city is o...原创 2018-04-25 19:11:04 · 193 阅读 · 0 评论 -
PAT(Advanced Level) 1003. Emergency(25) 最短路 + DFS
题目链接EmergencyTime limit:1 seconds Memory limit:256 megabytes Problem DescriptionIAs an emergency rescue team leader of a city, you are given a special map of your country. The map shows...原创 2018-03-07 23:31:18 · 247 阅读 · 0 评论 -
SPFA算法模板
const int INF=0x3f3f3f3f;const int maxm=511111;const int maxn=111111;struct EdgeNode{ int to; int w; int next;};EdgeNode edges[maxm];int N,M;int head[maxn],edge;bool vis[maxn];queue原创 2017-10-16 20:13:29 · 251 阅读 · 0 评论 -
计蒜客:热爱工作的蒜蒜(最短路)
题目链接热爱工作的蒜蒜Time limit:1000ms Memory limit:262144K Problem Description众所周知,蒜蒜是一名热爱工作的好员工,他觉得时间就是金钱,做事情总是争分夺秒。这天晚上,蒜蒜一个人去吃晚饭。不巧的是,吃完饭以后就开始下雨了,蒜蒜并没有带雨伞出来。但是蒜蒜热爱工作,工作使他快乐,他要尽快赶回去写代码。蒜蒜的公司在中关村,中关村这边地形复杂,有很原创 2017-10-25 13:26:30 · 501 阅读 · 0 评论 -
POJ 2367:Genealogical tree (拓扑排序)
Genealogical tree Time limit:1000 ms Memory limit:65536 kB OS:Linux Problem DescriptionThe system of Martians’ blood relations is confusing enough. Actually, Martians bud when they want and where they原创 2017-09-18 20:00:08 · 417 阅读 · 0 评论 -
POJ 1094:Sorting It All Out (拓扑排序)
Sorting It All OutTime limit:1000 ms Memory limit:65768 kB Problem DescriptionAn ascending sorted sequence of distinct values is one in which some form of a less-than operator is used to order the ele原创 2017-09-16 12:01:34 · 440 阅读 · 0 评论 -
Dijkstra算法模板
Dijkstra作者:刘伟#include <iostream>#include <stdlib.h>#include <algorithm>#define MAX 100#define INF 100000using namespace std;struct Graph{ int edges[MAX][MAX]; //邻接矩阵 int n;原创 2017-09-15 19:22:23 · 939 阅读 · 0 评论 -
Kruskal算法模板
Kruskal作者:刘伟#include <iostream>#include <algorithm>using namespace std;/* 定义边(x,y),权为w */struct edge{ int x, y; int w;};const int MAX = 26;edge e[MAX * MAX];int rank[MAX];/* rank[x]表示x的秩原创 2017-09-15 19:17:46 · 268 阅读 · 0 评论 -
CF#482:C Kuro and Walking Route(DFS)
题目链接Kuro and Walking Route题意无向图,n个点,n-1条边,每两个点都可以到达,但是从依次经过u,v两点的道路不能走,问有多少个x->y可以到达解题思路根据题意可知这是一个最小生成树,那么u到v只有一条道路可走 结果用总数减去A的数量×B的数量就可以了 确定数量用DFSCode#include "bits/stdc++.h"...原创 2018-05-15 21:05:29 · 713 阅读 · 0 评论