http://acm.hdu.edu.cn/showproblem.php?pid=3435 题意:有n个点和m条边,你可以删去任意条边,使得所有点在一个哈密顿路径上,路径的权值得最小. 思路: 费用流,注意判断重边,否则会超时. #include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<queue> using namespace std; ty…
http://acm.hdu.edu.cn/showproblem.php?pid=3435 #include <cstdio> #include <iostream> #include <cstring> #include <queue> #include <algorithm> #define inf 0x3f3f3f3f #define maxn 54444 using namespace std; queue<int>q; s…
Problem Description An undirected graph is a graph in which the nodes are connected by undirected arcs. An undirected arc is an edge that has no arrow. Both ends of an undirected arc are equivalent--there is no head or tail. Therefore, we represent a…
A new Graph Game Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1849    Accepted Submission(s): 802 Problem Description An undirected graph is a graph in which the nodes are connected by undir…
A new Graph Game Problem Description An undirected graph is a graph in which the nodes are connected by undirected arcs. An undirected arc is an edge that has no arrow. Both ends of an undirected arc are equivalent--there is no head or tail. Therefor…
6343.Problem L. Graph Theory Homework 官方题解: 一篇写的很好的博客: HDU 6343 - Problem L. Graph Theory Homework - [(伪装成图论题的)简单数学题] 代码: //1012-6343-数学 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<bitset&g…
给出n个点,m条边,入口s和出口t,对于每条边有两个值a,b,如果保留这条边需要花费:否则,移除这条边需要花费b. 题目要求用最小费用构造一个有向图满足以下条件: 1.只有一个入口和出口 2.所有路都是唯一方向 3.对于入口s,它的出度 = 它的入度 + 1 4.对于出口t,它的入度 = 它的出度 + 1 5.除了s和t外,其他点的入度 = 其出度 最后如果可以构造,输出最小费用:否则输出impossibe. 题解: 对于所有的边(u,v,a,b)我们先进行保留. 因为题目要求3和4.我们虚拟添…
http://acm.hdu.edu.cn/showproblem.php?pid=3488 题意: 给出n个点和m条边,每条边有距离,把这n个点分成1个或多个环,且每个点只能在一个环中,保证有解. 思路: 把一个点分成两部分,1~n和n+i~2*n. 连边的情况是这样的,(src,i,1,0),(i+n,dst,1,0). 如果两个点之间相同,则(i,j+n,1,d). 其实这道题目就是选n条边,如何使得权值之和最小. 具体请参考这http://blog.csdn.net/u013480600…
A new Graph Game Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2360    Accepted Submission(s): 951 Problem Description An undirected graph is a graph in which the nodes are connected by undire…
Rikka with Graph Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3367 Pseudoforest Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2870    Accepted Submission(s): 1126 Problem Description In graph theory, a pseu…
Cyclic Tour Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/65535 K (Java/Others)Total Submission(s): 2399    Accepted Submission(s): 1231 Problem Description There are N cities in our country, and M one-way roads connecting them. Now L…
http://acm.hdu.edu.cn/showproblem.php?pid=6141 题意: 求最大树形图. 思路: 把边的权值变为负值,那么这就是个最小树形图了,直接套模板就可以解决. 有个问题就是n结点的父亲结点的编号要尽量小,这里有个技巧可以用,权值编码,将所有边的权值都放大1000倍,对于和n相连的边,每条边在减去(n-u)的权值.这样就会去优先考虑编号小的边,而且因为权值最大为100,所以扩大1000是不会影响结果的. #include<iostream> #include&…
http://acm.hdu.edu.cn/showproblem.php?pid=1565 题意: 给你一个n*n的格子的棋盘,每个格子里面有一个非负数. 从中取出若干个数,使得任意的两个数所在的格子没有公共边,就是说所取的数所在的2个格子不能相邻,并且取出的数的和最大. 思路: 最大点权独立集=点权之和-最小点权覆盖集=最小割=最大流 先来看最小点权覆盖集,也就是选取点覆盖所有的边,并且权值要最小. 解决方法是: 从源点向X集连边,容量为点的权值,Y集向汇点连边,容量也为点的权值.如果u和v…
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6464 免费送气球 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 264    Accepted Submission(s): 53 Problem Description 又到了GDUT一年一度的程序设计竞赛校赛的时间啦.同学们只要参加校赛,…
Cyclic Tour Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/65535 K (Java/Others)Total Submission(s): 1197    Accepted Submission(s): 626 Problem Description There are N cities in our country, and M one-way roads connecting them. Now Li…
方格取数(1) Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7717    Accepted Submission(s): 2911 Problem Description 给你一个n*n的格子的棋盘,每个格子里面有一个非负数.从中取出若干个数,使得任意的两个数所在的格子没有公共边,就是说所取的数所在的2个格子不能相邻,并且取出的数…
这题是杭电多校2019第六场的题目 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6638 题意:给你平面上n个点,每个点都有权值(有负权),让你计算一个矩阵可能的最大覆盖权值和: 思路:用  连续最大子段-线段树  枚举上界,按行一行行更新线段树中的点,每插完一行就更新答案(类似枚举上下界),时间复杂度:O( n^2*log(n) ) : #define IOS ios_base::sync_with_stdio(0); cin.tie(0);…
题目大意:给出一个n个元素的数组A,A中所有元素都是不重复的[1,n].有两种操作:1.将pos位置的元素+1e72.查询不属于[1,r]中的最小的>=k的值.强制在线. 题解因为数组中的值唯一,且在1到n的范围内,而询问的r和k也在1到n的范围内. 所以对于任意一个被操 作1修改过的值都不会成为询问的答案,而询问的结果也必然在k到n+1的范围内. 因为没有被修改过 值是唯一的,所以可以建立权值线段树,维护权值区间内的值所在下标的最大值.而询问则转化为不小 于k的值里面,下标超过r的最小权值是多…
R - Weak Pair HDU - 5877 离散化+权值线段树 这个题目的初步想法,首先用dfs序建一颗树,然后判断对于每一个节点进行遍历,判断他的子节点和他相乘是不是小于等于k, 这么暴力的算法很自然的超时了. 然后上网搜了一下题解,感觉想的很巧妙. 就是我们要搜 子节点和父节点的乘积小于一个定值的对数. 一般求对数,有逆序对,都是把满足的放进去,到时候直接求答案就可以了.这个题目也很类似,但是还是有很大的区别的. 这个题目就是先把所有a[i] 和 k/a[i] 都放进一个数组,离散化,…
和HDU 3488一样的,只不过要判断一下是否有解. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <vector> using namespace std; + ; const int INF = 0x3f3f3f3f; int n, m; int W[maxn][maxn], lft[maxn]; int slack…
http://acm.hdu.edu.cn/showproblem.php?pid=5876 Sparse Graph Problem Description   In graph theory, the complement of a graph G is a graph H on the same vertices such that two distinct vertices of H are adjacent if and only if they are not adjacent in…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6343 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Problem DescriptionThere is a complete graph containing n vertices, the weight of the i-th vertex is wi.The length…
Rikka with Graph 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5631 Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them: Yuta has a non-direct gra…
Rikka with Graph Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 182    Accepted Submission(s): 95 Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation,…
http://acm.hdu.edu.cn/showproblem.php?pid=5424 哈密顿通路:联通的图,访问每个顶点的路径且只访问一次 n个点n条边 n个顶点有n - 1条边,最后一条边的连接情况: (1)自环(这里不需要考虑): (2)最后一条边将首和尾连接,这样每个点的度都为2: (3)最后一条边将首和除尾之外的点连接或将尾和出尾之外的点连接,这样相应的首或尾的度最小,度为1: (4)最后一条边将首和尾除外的两个点连接,这样就有两个点的度最小,度都为1 如果所给的图是联通的话,那…
题目地址:pid=1853">HDU1853 费用流果然好奇妙. .还能够用来推断环...假设每一个点都是环的一部分并且每一个点仅仅能用到一次的话,那每一个点的初度入度都是1,这就能够利用网络流来解决,仅仅要拆点令其流量为1.就限制了每一个点仅仅能用一次,每次左边的连到右边的.就相当于左边点的一次初度和右边的点的一次入度.非常easy想象出来. 最后仅仅要推断总流量是否为n就可以.由于假设总流量为n的话.说明每一个点都出了一次度.每一个点都入了一次度.并且由于拆点的流量限制.充分说明了每一…
Problem Description   As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them: Yuta has a non-direct graph with n vertices and n edges. Now he wants you to tell him…
Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them: Yuta has a non-direct graph with n vertices and m edges. The length of each edge . Now…
Cyclic Tour Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/65535 K (Java/Others) Total Submission(s): 1120    Accepted Submission(s): 579 Problem Description There are N cities in our country, and M one-way roads connecting them. Now L…