- 博客(11)
- 收藏
- 关注
原创 区间dp
#include<bits/stdc++.h>using namespace std;const int inf=1e9;int n;int a[310],s[310];int dp[310][310];int main(){ cin>>n; for(int i=1;i<=n;i++) cin>>a[i]; for(int i=1;i&...
2019-12-12 20:56:44
112
原创 背包dp模板
01背包#include<iostream>#include<cstring>using namespace std;const int maxn=1e5+1000;int n,m;int v[maxn],w[maxn];int dp[maxn];int main(){ cin>>n>>m; memset(dp,0,sizeof(...
2019-12-12 20:54:43
224
原创 poj2228 Naptime(环形dp)
DescriptionGoneril is a very sleep-deprived cow. Her day is partitioned into N (3 <= N <= 3,830) equal time periods but she can spend only B (2 <= B < N) not necessarily contiguous period...
2019-12-12 20:44:26
180
原创 ural 1018 Binary Apple Tree(树形dp)
DescriptionLet’s imagine how apple tree looks in binary computer world. You’re right, it looks just like a binary tree, i.e. any biparous branch splits up to exactly two new branches. We will enumera...
2019-12-12 20:21:45
186
原创 poj 2411 Mondriaan's Dream(状态压缩dp)
DescriptionSquares and rectangles fascinated the famous Dutch painter Piet Mondriaan. One night, after producing the drawings in his ‘toilet series’ (where he had to use his toilet paper to draw on, ...
2019-12-12 20:10:02
117
原创 Technocup 2020 - Elimination Round 3
A. Math Problem题意:有n个区间,判断被所有区间包括的最小区间的 l-r 的值;题解:取 “左边界中的最右点,右边界中最左点” 做差 int mixn=0; int maxn=inf; mixn=max(mixn,l); maxn=min(maxn,r); cout<<max(0,mixn-maxn)<<endl;...
2019-11-26 21:28:13
228
原创 差分约束
作用给出一些形如x-y<=b不等式的约束,询问是否满足有解。参考博客差分约束系统详解Note将约束为标题转换成图论里的最短路径问题求未知数的最大值,那么按小于等于建图后求最短路如果求未知数的最小值,那么按小于等于建图后求最长路即可。代码实现存储结构const int maxn=10010;const int inf=0x3f3f3f3f;int n,ml,md;in...
2019-11-15 20:01:21
122
原创 km算法
作用求二分图最大权完美匹配参考博客KM算法详解+模板代码实现存储结构const int maxn=310;const int inf=0x3f3f3f3f;int mmp[maxn][maxn]; // 记录每个妹子和每个男生的好感度bool book_gril[maxn];//标记被匹配过的人bool book_boy[maxn];int val_gril[maxn];//...
2019-11-06 20:39:23
1045
原创 匈牙利算法
作用寻找二分图最大匹配值参考博客趣写算法系列之–匈牙利算法代码实现存储结构const int maxn=1105;bool mp[maxn][maxn];//邻接矩阵存图bool vis[maxn]; //标记数组,一次递归中数据仅可被更改一次int mark[maxn];//找一个没被匹配过的,并更改值所需函数dfs递归找增广路bool dfs(int x){ for...
2019-11-06 09:15:59
223
原创 二分图基础知识
二分图定义顶点集V可分割为两个互不相交的子集,并且图中每条边依附的两个顶点都分属于这两个互不相交的子集,两个子集内的顶点不相邻。抽象理解:将人群分为男生和女生两部分,一对一的交往二分图匹配在二分图的一个子图M中,M的边集中的任意两条边都不依附于同一个顶点,则称M是一个匹配。最大匹配:(匈牙利算法)选择这样的边数最大的子集称为图的最大匹配问题,最大匹配的边数称为最大匹配数。完全匹配...
2019-11-05 19:05:14
352
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人