图论
文章平均质量分 69
兔兔不爱吃萝卜
小菜鸡在努力的呀
展开
-
L2-001 紧急救援 (25 分)(优化版dijkstra+路径存储)
#include <bits/stdc++.h>using namespace std;const int N=11111;int n,m,s,d;typedef pair<int,int>PII;int a[N],res[N];int h[N],ne[N],e[N],w[N],idx;int dist[N];bool st[N];int path[N],way[N],du[N]; // path 记录位置点,way 记录道路条数,du记录该点权值 void a.原创 2022-04-20 14:27:23 · 229 阅读 · 0 评论 -
最短路算法模板
最短路算法模板以下模板全部依据 此模板题 给出,一定要理解模板,具体题目请具体分析,不要死搬硬套另外,图论(最短路问题只是图论的一小部分)中一般有如下约定:•nnn 表示顶点数,mmm 表示边数•V/v(vertex)V/v(vertex)V/v(vertex) 表示顶点,E/e(edge)E/e(edge)E/e(edge) 表示边•uuu 表示起点(也叫源点),vvv 表示终点(也叫汇点),www 表示边权最短路算法模板目录•Dijkstra算法(包括朴素版和堆优化版)•Bellman-原创 2022-02-21 10:04:10 · 92 阅读 · 0 评论 -
最短路算法模板
最短路算法模板以下模板全部依据 此模板题 给出,一定要理解模板,具体题目请具体分析,不要死搬硬套另外,图论(最短路问题只是图论的一小部分)中一般有如下约定:•nnn 表示顶点数,mmm 表示边数•V/v(vertex)V/v(vertex)V/v(vertex) 表示顶点,E/e(edge)E/e(edge)E/e(edge) 表示边•uuu 表示起点(也叫源点),vvv 表示终点(也叫汇点),www 表示边权最短路算法模板目录•Dijkstra算法(包括朴素版和堆优化版)•Bellman-原创 2021-08-14 10:45:18 · 75 阅读 · 0 评论 -
J - Borg Maze(最小生成树+bfs)
这里写目录标题最小数二级目录三级目录最小数二级目录三级目录项目Value电脑$1600手机$12导管$1Column 1Column 2centered 文本居中right-aligned 文本居右原创 2021-08-13 10:14:07 · 113 阅读 · 0 评论 -
最小生成树算法模板
最小生成树算法模板以下模板全部依据 此模板题 给出,一定要理解模板,具体题目请具体分析,不要死搬硬套另外,图论(最短路问题只是图论的一小部分)中一般有如下约定:•nnn 表示顶点数,mmm 表示边数•V/v(vertex)V/v(vertex)V/v(vertex) 表示顶点,E/e(edge)E/e(edge)E/e(edge) 表示边•uuu 表示起点(也叫源点),vvv 表示终点(也叫汇点),www 表示边权最小生成树算法模板目录•Prim算法(包括朴素版和堆优化版)•Kruskal算原创 2021-08-12 10:35:57 · 65 阅读 · 0 评论 -
N - Is There A Second Way Left?(最小生成树,kruskal)
Nasa, being the most talented programmer of his time, can’t think things to be so simple. Recently allhis neighbors have decided to connect themselves over a network (actually all of them want to sharea broadband internet connection ????). But he wants t原创 2021-08-11 18:42:12 · 95 阅读 · 0 评论 -
O - ACM Contest and Blackout(最小生成树,kruskal)
In order to prepare the “The First National ACM School Contest” (in 20??) the major of the citydecided to provide all the schools with a reliable source of power. (The major is really afraid ofblackoutsJ). So, in order to do that, power station “Future”原创 2021-08-11 15:54:33 · 90 阅读 · 0 评论 -
H - Arctic Network(最小生成树)
The Department of National Defence (DND) wishes to connect several northern outposts by a wireless network. Two different communication technologies are to be used in establishing the network: every outpost will have a radio transceiver and some outposts w原创 2021-08-11 14:29:19 · 98 阅读 · 0 评论 -
E - Highways(最小生成树)
The island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has a very poor system of public highways. The Flatopian government is aware of this problem and has already constructed a number of highways connecting some of the most important tow原创 2021-08-11 09:11:04 · 83 阅读 · 0 评论 -
I - Constructing Roads(最小生成树)
There are N villages, which are numbered from 1 to N, and you should build some roads such that every two villages can connect to each other. We say two village A and B are connected, if and only if there is a road between A and B, or there exists a villag原创 2021-08-09 17:59:38 · 46 阅读 · 0 评论 -
K - 还是畅通工程(最小生成树)
某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离。省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可),并要求铺设的公路总长度为最小。请计算最小的公路总长度。Input测试输入包含若干测试用例。每个测试用例的第1行给出村庄数目N ( < 100 );随后的N(N-1)/2行对应村庄间的距离,每行给出一对正整数,分别是两个村庄的编号,以及此两村庄间的距离。为简单起见,村庄从1到N编号。当N为0时,输入结束,该用例不被处原创 2021-08-09 16:04:43 · 44 阅读 · 0 评论 -
J - Wormholes(bellman判断负权)
In the year 2163, wormholes were discovered. A wormhole is a subspace tunnel through space and timeconnecting two star systems. Wormholes have a few peculiar properties:• Wormholes are one-way only.• The time it takes to travel through a wormhole is neg原创 2021-08-02 18:05:50 · 49 阅读 · 0 评论 -
C - Currency Exchange(图论,最短路,bellman判断正负权)
Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations only with these currencies. There can be several points specializing in the same pair of curr原创 2021-08-02 17:56:01 · 130 阅读 · 0 评论 -
I - Two Paths
You are given a undirected graph with n nodes (numbered from 1 to n) and m edges. Alice and Bob are now trying to play a game.Both of them will take different route from 1 to n (not necessary simple).Alice always moves first and she is so clever that tak原创 2021-08-02 17:41:58 · 49 阅读 · 0 评论 -
F - Roadblocks(次短路)
B. Alphabetical Stringstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputA string s of length n (1≤n≤26) is called alphabetical if it can be obtained using the following algorithm:first, write an em原创 2021-07-30 18:50:39 · 147 阅读 · 1 评论 -
D - Six Degrees of Cowvin Bacon(最小路径)
The cows have been making movies lately, so they are ready to play a variant of the famous game “Six Degrees of Kevin Bacon”.The game works like this: each cow is considered to be zero degrees of separation (degrees) away from herself. If two distinct cow原创 2021-07-30 14:47:22 · 95 阅读 · 0 评论 -
B - Heavy Transportation(最短路+dijkstra变形)
BackgroundHugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way from the place his customer has build his giant steel crane to the place where原创 2021-07-28 16:38:05 · 64 阅读 · 0 评论 -
A - 最短路(图论+最短路)
It is a little known fact that cows love apples. Farmer John has two apple trees (which are conveniently numbered 1 and 2) in his field, each full of apples. Bessie cannot reach the apples when they are on the tree, so she must wait for them to fall. Howev原创 2021-07-23 09:57:16 · 58 阅读 · 0 评论