——图论相关——
文章平均质量分 83
LP_Cong
Python, Qt C++ Developer ACMer https://github.com/Linzecong
展开
-
Gym - 100548C The Problem Needs 3D Arrays (最大密度子图)
题意:求一个子序列,使得这个子序列的 逆序数/长度 最大 解题思路:如果知道什么是最大密度子图,那么这道题就是裸题了。这里保存一下模板~!感谢大佬的模板https://www.cnblogs.com/xiuwenli/p/9748771.html这个模板可以求 带点权带边权某些点必须用的最大密度子图 #include<bits/stdc++.h>...原创 2018-11-16 21:59:36 · 1083 阅读 · 2 评论 -
牛客国庆集训派对Day3 I-Metropolis (迪杰斯特拉堆优化)
链接:https://www.nowcoder.com/acm/contest/203/I来源:牛客网 题目描述魔方国有n座城市,编号为。城市之间通过n-1条无向道路连接,形成一个树形结构。在若干年之后,其中p座城市发展成了大都会,道路的数量也增加到了m条。大都会之间经常有贸易往来,因此,对于每座大都会,请你求出它到离它最近的其它大都会的距离。输入描述:第一行三个整数n,...原创 2018-10-03 20:24:56 · 346 阅读 · 0 评论 -
HDU - 6081 & 3691(无向图全局最小割)
用来保存全局最小割模板!全局最小割,即给定一个无向图,求得任意两点间的最小割。所有的最小割中最小的那个,就是全局最小割。接地气的讲,就是给定一个图,割掉某些边,使得整个图不再联通,权值最小的边集就是这个图的全局最小割。 Stoer-Wagner算法模板题,邻接表堆优化法理论复杂度O(nmlog(m))HDU - 6081#include <iostream...原创 2018-09-19 22:52:20 · 356 阅读 · 0 评论 -
HYSBZ - 1061 志愿者招募 (利用网络流流量平衡进行等式建模)
1061: [Noi2008]志愿者招募Time Limit: 20 Sec Memory Limit: 162 MBSubmit: 5862 Solved: 3529[Submit][Status][Discuss]Description 申奥成功后,布布经过不懈努力,终于成为奥组委下属公司人力资源部门的主管。布布刚上任就遇到了一个难题:为即将启动的奥运新项目招募...原创 2018-09-19 20:40:52 · 397 阅读 · 0 评论 -
CodeChef - RIN Course Selection (最小割建模)
出处:国家集训队2016论文集题目链接:https://vjudge.net/problem/CodeChef-RIN代码:https://www.cnblogs.com/shenben/p/6624196.html 容量正无穷的边表示冲突(某种前置关系) ...原创 2018-09-19 19:18:54 · 301 阅读 · 0 评论 -
HDU - 6437 Problem L.Videos (费用流)
Problem L.VideosTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 818 Accepted Submission(s): 418 Problem DescriptionC-bacteria takes...原创 2018-09-13 19:57:55 · 206 阅读 · 0 评论 -
计蒜客 Fantastic Grap(2018 ICPC亚洲区域赛网络赛 沈阳 F)(有上下界网络流)
"Oh, There is a bipartite graph.""Make it Fantastic."X wants to check whether a bipartite graph is a fantastic graph. He has two fantastic numbers, and he wants to let all the degrees to between the...原创 2018-09-10 19:24:52 · 291 阅读 · 0 评论 -
计蒜客 Modular Production Line(ACM-ICPC 2018 焦作赛区网络预赛 F)(最长k可重区间集问题 费用流)
An automobile factory has a car production line. Now the market is oversupply and the production line is often shut down. To make full use of resources, the manager divides the entire production line ...原创 2018-09-16 00:40:31 · 459 阅读 · 0 评论 -
计蒜客 Maze Designer(2018 ICPC亚洲区域赛网络赛 徐州 J)(最大生成树+LCA)
After the long vacation, the maze designer master has to do his job. A tour company gives him a map which is a rectangle. The map consists of N \times MN×M little squares. That is to say, the height o...原创 2018-09-11 11:29:54 · 269 阅读 · 0 评论 -
计蒜客 Magical Girl Haze (2018 ICPC亚洲区域赛网络赛 南京 L)(迪杰斯特拉)
题目链接:https://nanti.jisuanke.com/t/31001There 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 t...原创 2018-09-01 21:34:44 · 408 阅读 · 0 评论 -
2018年上海金马五校程序设计竞赛 Problem G : Can I Find You
Problem G : Can I Find YouFrom: DHUOJ, 2018060907Submit (Out of Contest)Time Limit: 3 sDescriptionOnce by chance, Chris met a lovely girl Melinda. They had a very pleasant conversation. But Chris forg...原创 2018-06-09 17:27:47 · 576 阅读 · 0 评论 -
HDU - 6290 奢侈的旅行 (最短路径)(2018CCPC女生赛)
奢侈的旅行Time Limit: 14000/7000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others)Total Submission(s): 189 Accepted Submission(s): 34Problem Description高玩小Q不仅喜欢玩寻宝游戏,还喜欢一款升级养成类游戏。在这个游戏的世界地...原创 2018-05-31 15:00:57 · 1703 阅读 · 0 评论 -
HDU - 5458 Stability (边双连通分量+树链剖分+线段树)
StabilityTime Limit: 3000/2000 MS (Java/Others) Memory Limit: 65535/102400 K (Java/Others)Total Submission(s): 2007 Accepted Submission(s): 470Problem DescriptionGiven an undirected connected gr...原创 2018-05-24 20:44:37 · 260 阅读 · 0 评论 -
HDU - 6280 From Tree to Graph (并查集+LCA)(2018CCPC湘潭邀请赛E)
From Tree to GraphTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 327680/327680 K (Java/Others)Total Submission(s): 11 Accepted Submission(s): 6Problem DescriptionBobo has a tree of n vert...原创 2018-05-24 16:59:27 · 480 阅读 · 0 评论 -
2018 ACM-ICPC 中国大学生程序设计竞赛线上赛 F. Clever King (最大权闭合子图)
Description: In order to increase the happiness index of people's lives, King Y has decided to develop the manufacturing industry vigorously. There are total n kinds of products that King can choos...原创 2018-04-23 22:40:27 · 843 阅读 · 0 评论 -
HDU - 6252 Subway Chasing (2017 CCPC FInal)(差分约束)
Subway ChasingTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 786 Accepted Submission(s): 258Special Judge Problem DescriptionMr. Pan...原创 2018-10-11 20:04:27 · 390 阅读 · 5 评论 -
牛客国庆集训派对Day6 A-Birthday (最小费用流)
链接:https://www.nowcoder.com/acm/contest/206/A来源:牛客网 题目描述恬恬的生日临近了。宇扬给她准备了一个蛋糕。正如往常一样,宇扬在蛋糕上插了n支蜡烛,并把蛋糕分为m个区域。因为某种原因,他必须把第i根蜡烛插在第ai个区域或第bi个区域。区域之间是不相交的。宇扬在一个区域内同时摆放x支蜡烛就要花费x2的时间。宇扬布置蛋糕所用的总时间是他在每个...原创 2018-10-06 19:27:57 · 273 阅读 · 0 评论 -
牛客国庆集训派对Day6 J-最短路 (任意两点间最短路径问题)
链接:https://www.nowcoder.com/acm/contest/206/J来源:牛客网 题目描述给一个连通图,每次询问两点间最短路。每条边的长度都是1。输入描述:第一行两个整数n和m,表示图的点数和边数(1≤ n≤ 100000, 1≤ m≤ n+100)。接下来m行每行两个整数a和b,表示一条边(1≤ a, b≤ n)。保证没有自环和重边。保证图连通。接...原创 2018-10-06 19:55:18 · 1066 阅读 · 0 评论 -
Gym - 101669D Harry Potter and The Vector Spell (最小生成树)
题意:求一个01矩阵的秩,这个矩阵的每一列只有两个1.解题思路:很容易联想到图论,我们对于每一列的两个一所在的行连边,最后形成一个图,最后的秩肯定是这个图最大的一个无环子图,其实就是最小生成树。 #include <iostream>#include <cstring>#include <algorithm>#include <...原创 2018-11-21 13:46:45 · 788 阅读 · 0 评论 -
Gym - 101986H Homework (最大流和最小割)
题意:有N个作业,分别为A类和B类,每天最多只能选择AB中的一类做,如果该天有该类的作业,就必须要做一个,问最多能做多少作业,和最少要做多少作业。 解题思路:对于最多能做多少,很容易建图对于每一天建一个点对于每一个作业建一个点每个作业覆盖的天都跟该作业连边,流量为1源点跟每一天连边,流量为1每一个作业跟汇点连边,流量为1.最大流即最多能做的作业。其实就...原创 2018-11-21 13:40:04 · 454 阅读 · 0 评论 -
Gym - 101986F Pizza Delivery (最短路必经路径)
题意:给你一个有向图,每一条边在第i天都会反向,问反向后的最短路是否有变化。每次反向都是独立的。 解题思路:我们先把起点到所有点的最短路求出来,然后把所有边反向,然后求终点到所有点的最短路。这样我们就记录了两个数组d1,d2,分别记录起点和终点到所有点的最短路。然后用s记录刚开始的最短路。当我们反向一条边的时候只需要判断 d1[v]+d2[u]+w<s,如果小于s,那么...原创 2018-11-21 13:25:17 · 1031 阅读 · 1 评论 -
hihoCoder - 1870 Jin Yong’s Wukong Ranking List (拓扑排序)(2018ICPC北京A)
时间限制:1000ms单点时限:1000ms内存限制:512MB描述Jin Yong was the most famous and popular Chinese wuxia (The one who fight bad people by his Wukong i.e. Wushu and Kongfu) novelist who lived in Hong Kong. Bet...原创 2018-11-12 19:34:04 · 810 阅读 · 0 评论 -
Gym - 101194G Pandaria (并查集+倍增+线段树合并)
题意:给定一个无向图。每个点有一种颜色。现在给定q个询问,每次询问x和w,求所有能通过边权值不超过w的边走到x的点的集合中,哪一种颜色的点出现的次数最多。次数相同时输出编号最小的那个颜色。强制在线。 解题思路:膜拜大神们的代码!看了好久,终于搞懂了。 我们假设有一个二维数组存储了所有答案ans[x][w],那么对于每次查询,我们直接输出答案即可。关键在于怎么快速计算这...原创 2018-11-15 15:32:03 · 606 阅读 · 0 评论 -
Gym - 101630J Journey from Petersburg to Mosc (最短路径) (2017–2018, NEERC – Northern Eurasia Finals)
题意:求最短路径,其中最短路径只算前K大的边。解题思路:枚举所有边权,然后对原图重新建图,如果边权小于当前枚举值,那么把他权值置为0,大于的话,让他减去当前枚举的大小。然后跑最短路即可。最后用d[N]+K*c[i]更新答案即可。以下是简单的证明:首先只算前k大的边的最短路肯定比真正的最短路要小。假设第K+1大的边为X,那么在最短路中,小于等于X的边的权值可以视为0....原创 2018-11-13 19:57:04 · 377 阅读 · 0 评论 -
CodeForces - 1046B Hyperspace Highways (广义圆方树)
B. Hyperspace Highwaystime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn an unspecified solar system, there are NN planets. A spa...原创 2018-11-10 17:28:03 · 391 阅读 · 0 评论 -
CodeForces - 884F Anti-Palindromize(费用流)
F. Anti-Palindromizetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA string a of length m is called antipalindromic iff m is ev...原创 2018-10-31 22:43:33 · 271 阅读 · 0 评论 -
CodeForces - 863F Almost Permutation(费用流)
F. Almost Permutationtime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputRecently Ivan noticed an array a while debugging his code. ...原创 2018-10-31 20:43:28 · 286 阅读 · 0 评论 -
CodeForces - 1000E We Need More Bosses(无向图缩点 + 树的直径)
E. We Need More Bossestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYour friend is developing a computer game. He has already ...原创 2018-10-20 14:50:22 · 305 阅读 · 0 评论 -
HYSBZ - 2960 跨平面 (平面图转对偶图 + 最小树形图)
2960: 跨平面Time Limit: 1 Sec Memory Limit: 256 MBSubmit: 387 Solved: 166[Submit][Status][Discuss]DescriptionInput 第一行两个整数n和m,表示点与线段的数目。 接下来n行,每行两个整数x和y,表示第i个点的坐标,点从1到n编号。 接下来m行,每行四个整数p...原创 2018-10-10 19:47:43 · 316 阅读 · 0 评论 -
Gym - 101908G Gasoline (二分+网络流)
G. Gasolinetime limit per test0.5 smemory limit per test1024 MBinputstandard inputoutputstandard outputAfter the end of the truck drivers' strike, you and the rest of Nlogônia logist...原创 2018-10-18 22:50:07 · 352 阅读 · 0 评论 -
Kattis - catering(WF2015)(有源汇有上下界费用可行流)
Paul owns a catering company and business is booming. The company has kk catering teams, each in charge of one set of catering equipment. Every week, the company accepts nn catering requests for vario...原创 2018-10-18 22:46:02 · 256 阅读 · 0 评论 -
Gym - 101889I Imperial roads (树链剖分维护边权最大值)
题意:给你一个图,然后Q个询问,每个询问,问强制要求使用某条边的情况下的最小生成树。 解题思路:先求最小生成树,然后对于强制要求的边,直接查询树上路径最大值,然后减去这个最大值,再加上要求的边的权值就是答案。 直接上树链剖分即可。 #include<bits/stdc++.h>using namespace std;const int MA...原创 2018-10-13 21:41:35 · 588 阅读 · 0 评论 -
Tarjan三大算法之双连通分量(双连通分量)
https://blog.csdn.net/fuyukai/article/details/51303292定义: 对于一个连通图,如果任意两点至少存在两条点不重复路径,则称这个图为点双连通的(简称双连通);如果任意两点至少存在两条边不重复路径,则称该图为边双连通的。点双连通图的定义等价于任意两条边都同在一个简单环中,而边双连通图的定义等价于任意一条边至少在一个简单环中。对一个无向图,点双连通的极...转载 2018-04-18 17:09:04 · 6542 阅读 · 0 评论 -
Gym 101606K Knightsbridge Rises(最大流+输出路径)
High-rise buildings in the wealthy retail district of Knightsbridge are usually built with exotichoisting machines known, in construction circles, as cranes.While it is common to mount these devices o...原创 2018-04-04 13:54:28 · 555 阅读 · 0 评论 -
POJ - 2762 Going from u to v or from v to u? (Tarjan 缩点)
Going from u to v or from v to u?Time Limit: 2000MS Memory Limit: 65536KTotal Submissions: 18552 Accepted: 4997DescriptionIn order to make their sons brave, J原创 2018-01-26 17:30:19 · 268 阅读 · 0 评论 -
POJ - 1236 Network of Schools (强连通分量)
Network of SchoolsTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 20402 Accepted: 8047DescriptionA number of schools are connected to a computer net原创 2018-01-26 15:01:14 · 210 阅读 · 0 评论 -
POJ - 2989 All Friends (极大团数量)
All FriendsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 2772 Accepted: 817DescriptionSociologists are interested in the phenomenon of "friendship".原创 2018-02-01 17:39:30 · 600 阅读 · 0 评论 -
POJ - 1419 (最大独立集 最大团问题)
Graph ColoringTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 5414 Accepted: 2526 Special JudgeDescriptionYou are to write a program that tries原创 2018-02-01 15:41:27 · 2511 阅读 · 3 评论 -
POJ - 3687 Labeling Balls (拓扑排序)
Labeling BallsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 15151 Accepted: 4420DescriptionWindy has N balls of distinct weights from 1 unit to N原创 2018-01-26 16:46:08 · 238 阅读 · 0 评论 -
GYM - 100812G Short Path (SPFA+思维)
Short Pathtime limit per test2.0 smemory limit per test256 MBinputstandard inputoutputstandard outputIn my opinion, people are divided into two categories: some原创 2017-12-02 19:37:07 · 336 阅读 · 0 评论