
图论
文章平均质量分 80
RJ28
小学生
展开
-
Codeforces Round #614 (Div. 1) D. Chaotic V.
"Everything has been planned out. No more hidden concerns. The condition of Cytus is also perfect.The time right now… 00:01:12…It’s time."The emotion samples are now sufficient. After almost 3 year...原创 2020-01-28 19:34:45 · 360 阅读 · 0 评论 -
Codeforces Round #407 (Div. 1) B. Weird journey
Little boy Igor wants to become a traveller. At first, he decided to visit all the cities of his motherland — Uzhlyandia.It is widely known that Uzhlyandia has n cities connected with m bidirectio原创 2017-04-02 23:23:17 · 518 阅读 · 0 评论 -
ICPCCamp Day1 C. City United(脑洞状压dp)
题目大意:给n(n 分析:原创 2017-03-10 21:07:51 · 467 阅读 · 0 评论 -
Codeforces Round #403 D. Axel and Marston in Bitland
A couple of friends, Axel and Marston are travelling across the country of Bitland. There are n towns in Bitland, with some pairs of towns connected by one-directional roads. Each road in Bitland is原创 2017-03-07 12:45:29 · 28869 阅读 · 0 评论 -
Codeforces Round #405 Div. 1 B. Bear and Tree Jumps
A tree is an undirected connected graph without cycles. The distance between two vertices is the number of edges in a simple path between them.Limak is a little polar bear. He lives in a tree that原创 2017-03-20 11:39:31 · 671 阅读 · 0 评论 -
Codeforces Round #397 E. Tree Folding(脑洞)
Vanya wants to minimize a tree. He can perform the following operation multiple times: choose a vertex v, and two disjoint (except for v) paths of equal length a0 = v, a1, ..., ak, and b0 = v, b原创 2017-03-08 10:12:34 · 290 阅读 · 0 评论 -
Codeforces Round #215 (Div. 1) C. Sereja and the Arrangement of Numbers(欧拉图)
Let's call an array consisting of n integer numbers a1, a2, ..., an, beautiful if it has the following property:consider all pairs of numbers x, y (x ≠ y), such that number x occurs in the a原创 2017-02-09 20:28:02 · 402 阅读 · 0 评论 -
Hdu-5915 The Fastest Runner Ms. Zhang(环套树DP)
Problem DescriptionMs. Zhang is a journalist from Hong Kong, and she runs very very fast, so every one calls her “The fastest runner”. There are n cities (numbered from 1 to n) and n roads in the co原创 2016-11-01 21:58:00 · 901 阅读 · 0 评论 -
CodeForces - 19E Fairy(图论 + DP)
DescriptionOnce upon a time there lived a good fairy A. One day a fine young man B came to her and asked to predict his future. The fairy looked into her magic ball and said that soon the fine you原创 2016-11-07 16:02:25 · 426 阅读 · 0 评论 -
Bzoj-3242 快餐店(环套树)
Description小T打算在城市C开设一家外送快餐店。送餐到某一个地点的时间与外卖店到该地点之间最短路径长度是成正比的,小T希望快餐店的地址选在离最远的顾客距离最近的地方。 快餐店的顾客分布在城市C的N 个建筑中,这N 个建筑通过恰好N 条双向道路连接起来,不存在任何两条道路连接了相同的两个建筑。任意两个建筑之间至少存在一条由双向道路连接而成的路径。小T的快餐店可以开设在任一建筑中,也原创 2016-11-04 21:15:01 · 458 阅读 · 0 评论 -
2014 Nordic Collegiate Programming Contest A - Amanda Lounges
题意:给n个点m条边的图,每条边有一个权重,表示两端点的权值和,每个点的权值为0或1,问所有点的最小权重。分析:类似2-SAT的方法对全图染色,注意每个点染两次,取最小值。#include#include#include#include#include#include#include#include#include#include#include#in原创 2016-09-08 19:49:41 · 539 阅读 · 0 评论 -
Codeforces Round #411 (Div. 1) D. Expected diameter of a tree(树的直径)
Pasha is a good student and one of MoJaK's best friends. He always have a problem to think about. Today they had a talk about the following problem.We have a forest (acyclic undirected graph) with原创 2017-05-09 22:37:35 · 822 阅读 · 0 评论 -
VK Cup 2017 - Round 3 D. Perishable Roads(最短路)
In the country of Never, there are n cities and a well-developed road system. There is exactly one bidirectional road between every pair of cities, thus, there are as many as roads! No two roads原创 2017-06-03 21:47:54 · 785 阅读 · 0 评论 -
Codeforces Round #420 (Div. 2) D. Okabe and City(最短路)
Okabe likes to be able to walk through his city on a path lit by street lamps. That way, he doesn't get beaten up by schoolchildren.Okabe's city is represented by a 2D grid of cells. Rows are numb原创 2017-07-21 21:04:31 · 293 阅读 · 0 评论 -
“今日头条杯”首届湖北省大学程序设计竞赛 网络赛-E.Jump A Jump(取模最短路)
Problem DescriptionThere's a very popular game called jump a jump recently.In order to get good marks, many people spend a lot of time in this game.Wei is the master of jump a jump,he can easily get a...原创 2018-04-21 15:24:38 · 717 阅读 · 0 评论 -
UVALive - 7042 The Problem to Make You Happy(博弈/bfs)
分析: 之前没怎么做过博弈相关的题目,一开始还以为是道复杂的分类讨论,设状态i,j,k表示当前Alice在i点Bob再j点且这一步轮到Alice/Bob操作,若dp[i][j][k]为1则表示Bob必败,那么我们考虑边界必败状态,一是两个点重叠在一起,二是现在轮到Bob操作而且Bob到了一个出度为0的点,有了这些状态后我们可以BFS出所有的必败点,根据题意那么剩下的点就一定是必胜点了。原创 2017-10-18 19:51:05 · 396 阅读 · 0 评论 -
Hdu-6200 mustedge mustedge mustedge(动态树+并查集)
Give an connected undirected graph with n nodes and m edges, (n,m≤105) which has no selfloops or multiple edges initially.Now we have q operations (q≤105): ⋅1 u v: add an原创 2017-09-11 15:42:17 · 403 阅读 · 0 评论 -
HYSBZ - 2959 长跑(动态树+并查集)
某校开展了同学们喜闻乐见的阳光长跑活动。为了能“为祖国健康工作五十年”,同学们纷纷离开寝室,离开教室,离开实验室,到操场参加3000米长跑运动。一时间操场上熙熙攘攘,摩肩接踵,盛况空前。 为了让同学们更好地监督自己,学校推行了刷卡机制。 学校中有n个地点,用1到n的整数表示,每个地点设有若干个刷卡机。 有以下三类事件: 1、修建了一条连接A地点和B地点的跑道。 2、A原创 2017-09-11 10:46:26 · 303 阅读 · 0 评论 -
ACM-ICPC国际大学生程序设计竞赛北京赛区(2017)网络赛 Agent Communication(图论)
描述In Peking University, there are many homeless cats. The students of cat club built n nests and some paths for those cats. A path connects two nests directly. All nests are connected by paths and t原创 2017-09-25 19:39:05 · 621 阅读 · 0 评论 -
2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛 Colored Graph(贪心构造)
In graph theory, graph colouring is a special case of graph labelling.It is an assignment of labels traditionally called colours to edges of a graph.Here we consider the simplest form.Given an u原创 2017-09-14 00:02:30 · 323 阅读 · 0 评论 -
UESTC-1633 去年春恨却来时,落花人独立,微雨燕双飞(取模最短路)
给你一个大小为n的集合S,集合里有n个互不相同正整数.有q个询问,每次询问是否能选择S中的一些数字 ( 同一个数字可以选择多次,也可以任何数字都不选),使它们相加的和为m.Input第一行一个数n(1≤n≤2000),表示集合S的大小.第二行n个数,第i个数ai(1≤ai≤50000)表示集合S中的第i个数.第三行一个数q(1≤q≤10000),表示询问次数.接下来q行,每行一个数m(0≤m≤10...原创 2017-08-05 12:05:01 · 897 阅读 · 0 评论 -
Hdu-6071 Lazy Running(trick最短路)
In HDU, you have to run along the campus for 24 times, or you will fail in PE. According to the rule, you must keep your speed, and your running distance should not be less than KK meters. There a原创 2017-08-04 17:00:26 · 321 阅读 · 0 评论 -
Hdu-6035 Colorful Tree(dfs)
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 375 Accepted Submission(s): 126Problem DescriptionThere is a tree with n node原创 2017-07-25 23:37:30 · 961 阅读 · 1 评论 -
Codeforces Round #170 (Div. 1) E. Binary Tree on Plane(费用流)
A root tree is a directed acyclic graph that contains one node (root), from which there is exactly one path to any other node.A root tree is binary if each node has at most two outgoing arcs.W原创 2017-07-21 21:11:22 · 368 阅读 · 0 评论 -
LA 7334 Kernel Knights
题意:有2*n个骑士(二分图),要求你求一个集合,这个集合内的所有点之间没有边,且这个集合连出去的所有边能覆盖住出去这个集合外的所有点。分析:我们把最左边的点全部加入这个集合,然后把所有没有覆盖到的点都加入队列,然后依次处理队列中的元素,队列中的元素都要冲新加入集合,且它们连出的点都一定不再集合中,那么去除这些点又会新产生一些点没有被覆盖,我们再把它们加入队列依次循环。。。原创 2016-08-10 23:16:37 · 631 阅读 · 0 评论 -
Hdu-5765 Bonds(状压)
Problem DescriptionGiven an undirected connected graph with N points and M edges. ?? wants to know the number of occurrence in all bonds of graph for every edge.The index of points starts from 0.A原创 2016-08-11 01:02:54 · 361 阅读 · 0 评论 -
LA 3211 Now or later(2-SAT)
题意:有n架飞机,每架飞机有早着陆和晚着陆两种选择,而且必须选择一种,第i架飞机的早晚着陆时间分别为Ei Li,问你相邻两架飞机的着陆间隔的最小值的最大值是多少。分析:每个飞机有早晚着陆两种选择,若i早着陆则xi为1否则为0,适用于2-SAT模型,我们可以二分时间间隔然后判断能不能有合法的赋值方案。#include #include #include #inc原创 2016-07-27 14:30:53 · 378 阅读 · 0 评论 -
LA 3523 Knights of the Round Table(点双连通分量+二分图判断)
题意:有n个骑士经常举行圆桌会议,商讨大事,每次圆桌会议至少应有3个骑士参加,且互相憎恨的骑士不能坐在圆桌旁的相邻位置,如果发生意见分歧,则需要举手表决,因此参加会议的骑士数目必须是奇数,以防赞同和反对票一样多,知道哪些骑士互相憎恨之后,你的任务是统计有多少个骑士不可能参加任何一个会议。分析:求出原图的补图后,问题转化为判断一个点是否存在一个奇数环内,一个环内的所有点一定在同一个点双联原创 2016-07-24 15:37:56 · 421 阅读 · 0 评论 -
LA 4287 Proving Equivalences(强连通分量缩点)
题意:给出n个节点m条边的有向图,要求添加尽量少的边,使得新图强连通。分析:求出所有强连通分量缩点后,再求出所有入度出度为0的点的个数,输出其最大值即可,注意强连通分量个数为1时输出0。#include #include #include #include #include #include #include #incl原创 2016-07-24 20:13:44 · 303 阅读 · 0 评论 -
LA 5135 Mining Your Own Business(点双连通分量+贪心)
题意:在一个无向图中选择尽量少的点涂黑,使得任意删除一个点后,每个连通分量至少有一个黑点,问你最少选几个点和其方案数。分析:求出所有点双连通分量后,构造block forest data structure,很容易发现我们只需染”叶子虚点“下的点就可以了,注意当全图为一个连通分量时答案为2,方案为n*(n-1)/2。#include #include #include原创 2016-07-24 17:44:39 · 977 阅读 · 0 评论 -
Hdu-5739 Fantasia (图论点双连通分量+DP)
Problem DescriptionProfessor Zhang has an undirected graph G with n vertices and m edges. Each vertex is attached with a weight wi. Let Gi be the graph after deleting the i-th vertex f原创 2016-07-23 22:58:36 · 636 阅读 · 0 评论 -
UVA-11383 (KM算法)
直接套KM模板。原创 2016-02-25 23:45:43 · 390 阅读 · 0 评论 -
POJ-1789
Truck History Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 23300 Accepted: 9019Description Advanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are use原创 2016-02-19 00:37:09 · 296 阅读 · 0 评论 -
Gym 100917 F - Find the Length
time limit per test4 seconds (5 seconds for Java)memory limit per test256 megabytesinputstandard inputoutputstandard outputFor each vertice of given undirected weighted graph c原创 2016-03-29 13:48:18 · 701 阅读 · 0 评论 -
bzoj-1103 [POI2007]大都市meg
1103: [POI2007]大都市megTime Limit: 10 Sec Memory Limit: 162 MBSubmit: 1056 Solved: 521[Submit][Status]Description在经济全球化浪潮的影响下,习惯于漫步在清晨的乡间小路的邮递员Blue Mary也开始骑着摩托车传递邮件了。不过,她经常回忆起以前在乡间漫步的情景。昔日原创 2016-02-16 20:34:20 · 564 阅读 · 0 评论 -
LA 3713 Astronauts(2-SAT)
题意:有A,B,C三个任务要分配给n个宇航员,其中每个宇航员好分配一个任务,所有宇航员的平均年龄是X,大于等于X的才能做A任务,小于X的才能做B任务,有m对宇航员互相讨厌不能分配到一个任务,求一个任务分配方案。分析:依然是2-SAT模型,设xi表示是否不做C任务,若宇航员i和j互相讨厌且都大于X,则xi != xj,若i和j的年龄段不同,则xi or xj。#include原创 2016-07-27 15:13:02 · 420 阅读 · 0 评论 -
Uva 10917 Walk Through the Forest(DAG拓扑排序)
题意:jimmy下班需要穿过一个森林,所以打算每天沿着一条不同的路径回家,他只沿着满足如下条件的(A,B)走:存在一条从B出发的回家路,比所有从A出发的回家路都短,问你一共有多少种回家方案,1为家,2为起点。分析:求一遍从2开始的单元最短路,然后从新构图,只保留d(a) > d(b) 的 (b,a)边,注意这一定是一个DAG(有向无环图),然后拓扑排序后DP。#原创 2016-07-27 16:42:00 · 429 阅读 · 0 评论 -
Codeforces Round #363 (Div. 2) D. Fix a Tree (并查集)
A tree is an undirected connected graph without cycles.Let's consider a rooted undirected tree with n vertices, numbered1 through n. There are many ways to represent such a tree. One way is to cre原创 2016-07-20 10:17:21 · 541 阅读 · 0 评论 -
Poj-1741 Tree(树的点分治)
DescriptionGive a tree with n vertices,each edge has a length(positive integer less than 1001).Define dist(u,v)=The min distance between node u and v. Give an integer k,for every pair (u,v)原创 2016-09-12 23:44:07 · 407 阅读 · 0 评论 -
Codeforces Round #364 (Div. 1) C. Break Up (桥)
Again, there are hard times in Berland! Many towns have such tensions that even civil war is possible.There are n towns in Reberland, some pairs of which connected by two-way roads. It is not guar原创 2016-09-12 01:38:46 · 412 阅读 · 0 评论