图论
文章平均质量分 86
bekote
这个作者很懒,什么都没留下…
展开
-
图论 || 二分图(过山车)
RPG girls今天和大家一起去游乐场玩,终于可以坐上梦寐以求的过山车了。可是,过山车的每一排只有两个座位,而且还有条不成文的规矩,就是每个女生必须找个个男生做partner和她同坐。但是,每个女孩都有各自的想法,举个例子把,Rabbit只愿意和XHD或PQK做partner,Grass只愿意和linle或LL做partner,PrincessSnow愿意和水域浪子或伪酷儿做partner。考虑...原创 2018-03-15 16:17:05 · 334 阅读 · 0 评论 -
图论 || Silver Cow Party(单向边来回最短路径)
I - Silver Cow Party One cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1..N is going to attend the big cow party to be held at farm #X (1 ≤ X ≤ N). A total of M (1 ≤ M≤ 100,000) un...原创 2018-09-21 17:33:27 · 353 阅读 · 0 评论 -
图论 || 最短路径(dij vs spfa)
F - Til the Cows Come HomeBessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty ...原创 2018-09-14 22:49:01 · 284 阅读 · 0 评论 -
图论 || 次短路
Roadblocks POJ - 3255 Bessie has moved to a small farm and sometimes enjoys returning to visit one of her best friends. She does not want to get to her old home too quickly, because she likes the ...原创 2018-09-25 00:11:38 · 236 阅读 · 0 评论 -
补题向 | Tree with Small Distances(树、贪心)
E. Tree with Small Distances由n个点和n-1条边组成的树,求最少添加多少条边,能使点1到其他点距离<=2将所有距离>2的点降序排序,连接点1和距离>2的点的父节点#include<stdio.h>#include<vector>#include<algorithm>#include<...原创 2018-09-06 16:12:22 · 558 阅读 · 0 评论 -
补题向 | Magical Girl Haze(dijkstra堆优化+分层图)
Magical Girl HazeThere are NN cities in the country, and MM directional roads from uu to v(1\le u, v\le n)v(1≤u,v≤n). Every road has a distance c_ici. Haze is a Magical Girl that lives in City 11, ...原创 2018-09-03 16:18:00 · 321 阅读 · 0 评论 -
补题向 | Mouse Hunt(图)
Mouse Huntn个房间,每个房间只通往(单向)另外一个房间(可能是自己),每个房间设陷阱花费的金额为ci,有一只老鼠,可能在任何一个房间,求为保证一定能捉住老鼠,设陷阱的最小花费金额将每个房间看为点,每个点只有一条出边或没有出边,陷阱只需要设在两类点上第一类点是没有出边的点,所有点将其入边保存为反向边,当找到没有出边的点时,顺着反向边删除所有能到达此点的入点(标记)把...原创 2018-08-21 23:23:18 · 542 阅读 · 0 评论 -
补题向 | ccpc网络预选赛—I Tree and Permutation
There are NN vertices connected by N−1N−1 edges, each edge has its own length. The set { 1,2,3,…,N1,2,3,…,N } contains a total of N!N! unique permutations, let’s say the ii-th permutation is PiPi and...原创 2018-08-27 00:06:57 · 314 阅读 · 0 评论 -
图论 || 最大流(牛)
DiningCows are such finicky eaters. Each cow has a preference for certain foods and drinks, and she will consume no others.Farmer John has cooked fabulous meals for his cows, but he forgot to check hi...原创 2018-04-26 14:20:05 · 1119 阅读 · 0 评论 -
图论 || Prim优化(畅通工程)
#include<stdio.h> #include<memory.h> #include<iostream> #include<algorithm> #include<vector> #include<algorithm> #include<math.h>#include<原创 2018-04-10 13:48:08 · 146 阅读 · 0 评论 -
图论 || Kruskal、Prim(畅通工程)
某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离。省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可),并要求铺设的公路总长度为最小。请计算最小的公路总长度。 Input测试输入包含若干测试用例。每个测试用例的第1行给出村庄数目N ( < 100 );随后的N(N-1)/2行对应村庄间的距离,每行给出一对正整数,...原创 2018-03-06 13:43:00 · 199 阅读 · 0 评论 -
图论 || Prim(最小生成树)
Prim:假设有一棵只包含一个顶点的树T,贪心地选取T和其他顶点之间相连的最小权值的边,并把它加入T中,不断进行此操作直到所有点都已加入,就可以得到最小生成树#include<iostream>#include<stdio.h>#include<algorithm>#include<vector>#define MAX 100000000u...原创 2018-03-04 23:15:33 · 177 阅读 · 0 评论 -
数据结构 || 图论 || 并查集+最小生成树(kruskal)
Connect the CitiesProblem DescriptionIn 2100, since the sea level rise, most of the cities disappear. Though some survived cities are still connected with others, but most of them become disconnected....原创 2018-03-04 22:36:43 · 155 阅读 · 0 评论 -
刷题向 | 最短路相关
求最短路条数和最短路经过的点的权重和最大值基本按照dij最短路做,更新时距离相等时也要更新,但是距离相等时经过点的权重和要取大值#include<stdio.h>#include<vector>#include<algorithm>#include<string.h>#include<iostream>#inclu...原创 2018-11-11 22:01:53 · 128 阅读 · 0 评论