自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(35)
  • 收藏
  • 关注

原创 hdu 2819 网格图 与2分匹配

给出ac代码:

2020-01-05 18:56:15 134

原创 acm的几种输入

整行读入再处理#include #include string ling;int p;getline(cin,ling);stringstream ss(ling);while(ss>>p)op( p);double 型 读入 lf;float 型 读入 f;输出都是 f ;

2019-11-26 17:49:11 225

原创 poj3134 加成序列 迭代加深+剪枝

永远永远不要忽视剪枝的力量!!!!不要觉得用了迭代加深或ida*之类的就不用剪枝这题就因为一个剪纸,搞得心态都快崩了,因为分类到是迭代加深所以没有怀疑是做法的错误,而是debug了半天,最后加了个剪纸就好了,原来搜索211次方花了大概10秒还是一分钟,剪纸后212或13次方1秒都不到就算出了了,,,剪纸真就很可怕!!以下给出ac代码:...

2019-11-09 14:51:49 183

原创 poj 2195 费用流模板题

费用流模板题每个人到每个房子建立一条流量为1,费用为曼哈顿距离的边,然后跑一遍最小费用流即可;#include <string.h>#include <stdio.h>#include <algorithm>#include <math.h>#include <queue>using namespace std;cons...

2019-09-30 16:35:11 163

原创 p3384 树链剖分模板题

线段树 在图论里面的应用线段树是处理区间问题的在图论的树里面的应用就是通过重链的方式dfs编号,形成一段连续的区间,就可以用线段树来处理了;能做到的事情为如题,已知一棵包含N个结点的树(连通且无环),每个节点上包含一个数值,需要支持以下操作:操作1: 格式: 1 x y z 表示将树从x到y结点最短路径上所有节点的值都加上z操作2: 格式: 2 x y 表示求树从x到y结点最短路径...

2019-09-10 14:27:06 90

原创 p3572 单调队列优化dp模板题

以下给出ac代码:#include <stdio.h>#include <algorithm>#include <string.h>#include <queue>using namespace std;const int maxn=1e6+7;int h[maxn],q[maxn],head,tail,dp[maxn];int n...

2019-09-09 18:54:05 115

原创 p1607 庙会班车 区间贪心加线段树

假如只有一辆班车,就是典型的普通区间贪心,贪心的维护终点从小到大选即可但是有多辆班车,其实也是一样的可以按终点贪心,然后线段树维护某段区间的班车用了多少就可以了,然后还有就是他这区间是左闭右开的,所以需要添加牛时,右端点-1;以下给出线段树版ac代码,据说数据水,貌似暴力不用线段树也能过;#include <stdio.h>#include <string.h>#...

2019-09-09 15:32:24 123

原创 hdu 1695 gcd 莫比乌斯反演模板题

#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;typedef long long ll;const int maxn=1e5+7;int prime[maxn],mu[maxn],tot;bool p[maxn];ll sum[maxn]...

2019-09-04 16:38:31 105

原创 p2257 yy的gcd 莫比乌斯反演入门题

ans=看着大佬推的式子 敲代码a了,感觉还得自己练一下推式子的能力#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;typedef long long ll;const int maxn=1e7+7;int prime[maxn],mu[m...

2019-09-04 11:46:56 126

原创 p3121 ac自动机的运用

比较裸的ac自动机的运用以下给出ac代码#include <stdio.h>#include <string.h>#include <algorithm>#include <queue>using namespace std;const int maxn=1e5+7;int trie[maxn][26],cnt,fail[maxn]...

2019-08-22 01:44:53 157

原创 p4824 kmp算法的运用

kmp算法的灵活运用#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;const int maxn=1e6+7;char s[maxn],t[maxn];int nxt[maxn];int stk[maxn],top,p[maxn];int...

2019-08-21 10:00:34 119

原创 P3041AC自动机+dp

第一道ac自动机加dp的题目1a了很开心据说ac自动机的dp都是有套路的,就是状态表示大都是2维,dp[i][j],表示串匹配了i个,最后一位停留在了trie图的j号点上了这题是模板题,以下给出ac代码#include <stdio.h>#include <string.h>#include <algorithm>#include <que...

2019-08-21 06:24:36 161

原创 p3808 ac自动机模板

ac自动机模板#include <stdio.h>#include <string.h>#include <algorithm>#include <queue>using namespace std;const int maxn=1e6+7;int trie[maxn][26],idx,val[maxn],fail[maxn];ch...

2019-08-19 09:24:59 74

原创 p3805manacher算法模板

manacher算法模板用于求字符串最大回文子串的算法,其思想和kmp有异曲同工之妙,都是先暴力,再利用已有信息来降低复杂度时间复杂度为O(n)空间复杂度为O(n)#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;const int maxn...

2019-08-17 04:03:31 117

原创 p3375 kmp匹配算法模板

#include <stdio.h>#include <string.h>using namespace std;const int maxn=1e6+7;int nxt[maxn];char s1[maxn],s2[maxn];int n,m;int main(){ scanf("%s%s",s1+1,s2+1);n=strlen(s1+1),...

2019-08-15 20:08:54 172

原创 主席树模板 p3834

应该是主席树的最普通最简单的应用,没有修改操作,查询静态区间第k小;#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;const int maxn=2e5+7;int root[maxn],idx,cnt=1,g[maxn],li[maxn];...

2019-08-12 06:22:28 122

原创 p3372线段树模板

线段树,求和版模板#include <stdio.h>#include <string.h>#include using namespace std;typedef long long ll;const int maxn=1e5+7;ll seg[maxn<<2],lazy[maxn<<2],g[maxn];int n,m;inli...

2019-08-08 23:49:43 89

原创 p3368树状数组的拓展运用

一般的树状数组是单点修改,可以查询前缀和,从而做到查询区间和,两者的时间复杂度都是o(logn)不过树状数组存储的是原数组的差分数组的话,就可以做到区间修改和查询单点的值用两个树状数组就可以起到线段树的作用,不过常数可能大点,而且貌似只能做到加的操作,不过代码少啊,不过真正要学习和常用的还是线段树吧,功能更强大,树状数组还是搞一下逆序对就完了#include <stdio.h>...

2019-08-08 23:03:19 102

原创 p1774 逆序对的理解

#include <stdio.h>#include <string.h>#include using namespace std;typedef long long ll;const int maxn=5e5+7;ll g[maxn],c[maxn],li[maxn],cnt;int n;inline int lowbit(int x){return x&...

2019-08-08 21:30:55 175

原创 p1908逆序对 数状数组的运用

数状数组的运用+哈希的思想 可以统计数组的逆序对p1908 逆序对模板题#include <stdio.h>#include <string.h>#include using namespace std;typedef long long ll;const int maxn=5e5+7;int h[maxn],li[maxn],cnt,c[maxn];in...

2019-08-08 21:29:36 134

原创 p1434记忆化搜索(dfs)滑雪

裸的模板题#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;const int maxn=110;int g[maxn][maxn],dp[maxn][maxn];int n,m;int dx[4]={-1,0,1,0},dy[4]={0,1...

2019-08-08 03:16:44 105

原创 树状数组 模板

```#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;const int maxn=5e5+7;int c[maxn];int n,m;inline int lowbit(int x){return x&(-x);}void...

2019-08-04 17:58:19 73

原创 单调栈的运用

单调栈可以用来是实现在 离线的情况下,O(n)的处理出数组中所有点比某个点小或大最近的距离是多少;具体做法是用栈来维护一边的点的下表,由于假如i<j hi>hj 那么h【i】便永无出头之日;可以把他删了,而在栈里能找到的直到第一次出现的小与hi的h【j】就一定是最近的,每个点出栈一次,进栈一次,所以时间复杂度是on的;例题是acwing 131和152以下给出ac代码...

2019-07-02 01:10:54 80

原创 网络流 p1345最小割点 模板建图与思考

题目描述农夫约翰的奶牛们喜欢通过电邮保持联系,于是她们建立了一个奶牛电脑网络,以便互相交流。这些机器用如下的方式发送电邮:如果存在一个由c台电脑组成的序列a1,a2,...,a(c),且a1与a2相连,a2与a3相连,等等,那么电脑a1和a(c)就可以互发电邮。很不幸,有时候奶牛会不小心踩到电脑上,农夫约翰的车也可能碾过电脑,这台倒霉的电脑就会坏掉。这意味着这台电脑不能再发送电邮了,于是与...

2019-06-28 00:14:39 238

原创 数论 模板

跟着yxc大佬的脚步,开启acm数论的篇章,也作些总结,写一些博客;线性筛,筛素数:```#include <stdio.h>using namespace std;const int maxn=1e7+7;int prime[maxn],cnt;bool vis[maxn];void get_prime(int n){ for(int i=2;i&l...

2019-06-27 16:45:57 100

原创 网络流 p2507 模板题学习建图

题目描述幼儿园里有n个小朋友打算通过投票来决定睡不睡午觉。对他们来说,这个问题并不是很重要,于是他们决定发扬谦让精神。虽然每个人都有自己的主见,但是为了照顾一下自己朋友的想法,他们也可以投和自己本来意愿相反的票。我们定义一次投票的冲突数为好朋友之间发生冲突的总数加上和所有和自己本来意愿发生冲突的人数。我们的问题就是,每位小朋友应该怎样投票,才能使冲突数最小?输入输出格式输入格式:...

2019-06-27 16:17:33 141

原创 超级读入与输出 神器

借鉴一篇朋友a题的代码,半夜看到笑得肚子疼;超级读入与输出 直接卡过```#include <bits/stdc++.h>using namespace std;namespace fastIO{ #define BUF_SIZE 100000 #define OUT_SIZE 100000 #define ll long long //...

2019-06-27 03:31:44 93

原创 数独 两种难度

数独一 9*9型的不明白的可以私戳加我q或去acwing上给我留言提问ac代码:```#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;const int maxn=9;char str[100];int row[maxn],co...

2019-06-27 03:17:13 633

原创 网络流24题 P2756 飞行员配对方案问题 最大流或最大匹配 两种方法过

法1:二分图模板题ac代码:30ms```#include <stdio.h>#include <string.h>using namespace std;const int maxn=210;int h[maxn],e[maxn*4],ne[maxn*4],idx;int match[maxn];bool vis[maxn];int n,m,...

2019-06-25 17:48:14 253 1

原创 poj 1273 最大流 模板

```#include <stdio.h>#include <string.h>#include <queue>#include <algorithm>using namespace std;const int maxn=210,inf=0x3f3f3f3f;int h[maxn],e[maxn*2],ne[maxn*2],w[ma...

2019-06-25 16:30:53 92

原创 洛谷 p3381 最小费最大流 模板题 spfa算法

大体思路是 spfa找能从起点流到终点的最短路,找到不能找了,就找到了最大流,而此时的费用一定是最小费用;以下给出ac代码:h[],e[],ne[] 存图, w[],f[],存每条边的流量和单位费用pre[],last[] 存修改增广路径的点和边dis[],flow [] 存到点的花费和流量```#include <stdio.h>#include &...

2019-06-25 11:09:43 266

原创 hdu 2196 树的直径的应用

网上看到很多关于这题的博客是用树形dp做的,代码还挺复杂的要求最远距离和次远距离,个人感觉不用这么麻烦,用三次dfs就行了,,用的的性质是 我们可以发现树上离某点最远的点一定是到树的直径的端点其中的一个,证明也是树的直径求法的证明,若点在直径上,从定义就可以证明,若不在直径上的点,此点到最远点的路径一定与直径相交,那点到交点的距离是确定的,那么交点继续往后的最远点就是交点了;第一次dfs 随...

2019-06-23 10:25:42 128

原创 hdu1050 贪心

The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure.The floor has 200 rooms each on the north side and south side along the corrid...

2019-06-15 16:12:29 162

原创 hdu 1069 线性dp LIS变形题

Monkey and BananaTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 23070 Accepted Submission(s): 12365Problem Description A group of researc...

2019-06-14 15:43:44 146

原创 算法竞赛进阶指南 位运算与状态dp经典入门题 最短哈密顿路径

题目描述给定一张 nn 个点的带权无向图,点从 0~n-1 标号,求起点 0 到终点 n-1 的最短Hamilton路径。 Hamilton路径的定义是从 0 到 n-1 不重不漏地经过每个点恰好一次。输入格式第一行输入整数nn。接下来nn行每行nn个整数,其中第ii行第jj个整数表示点ii到jj的距离(记为a[i,j])。对于任意的x,y,zx,y,z,数据保证 a[x,x]=0...

2019-06-05 04:57:10 200

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除