自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Mandsnow 0w0

momoshijiandalao

  • 博客(61)
  • 收藏
  • 关注

原创 Trilium使用小记

笔者由于做人浮躁,做事看东西都是三分钟热度,学习态度不端正,总是今天检索到了好东西可是太多看不完,第二天就怎么找也找不到了,为了避免错过互联网优秀资源,寻求过很多方法,比如:1.Instapaper 这也是一个很好用的稍后阅读工具,可以同步,ios、安卓端有应用,PC可以直接通过网页打开,只需要在浏览器上装一个小小的插件,想读但没时间或者想保存的文章、网页都可以存下俩以后慢慢看,可以进行分类,不过由于某种原因,或网络或功能单一或……总之,后来我就慢慢不再使用它了;2.印象笔记 懂得都懂,无奈之举,还

2022-04-06 11:14:35 9615

原创 codevs 1166 矩阵取数游戏 (2007 noip)

首先可以判断这是一个dp,然后这个矩阵中各个行之间是没有联系的,所以可以一行一行地求出最优解然后通过循环加起来不是一个特别难的dp 但是在数目问题上比较大 反正一看到平方啊这种东西应该差不多会溢出的……所以写一个高精度的结构体 就ok了!!代码在这:#include <bits/stdc++.h>#include <iostream>using namespace s...

2018-03-23 16:58:50 719

原创 hdu 2072 单词数(C++的stringstream对象)

#include #include #include #include using namespace std;int main(){ string s; while (getline(cin, s)){ if (s == "#"){ break; } stringstream in(s);

2017-03-11 11:42:47 442

原创 hdu 5952 Counting Cliques(最大团思想+dfs)

虽然是暴搜,但是也用到了最大团思想的代码:#include #include #include #include #include using namespace std;const int maxn=105;int t;int u,v;int n,m,a;int ans;int map[maxn][maxn];void clique(int l,int u[],i

2016-11-08 20:54:36 447

原创 codevs 1048能量项链(区间DP)

这么短的能量项链!!!代码在这:#include using namespace std;int s[2010];int dp[2010][2010];int main(){ int n; int maxn=0; scanf("%d",&n); for(int i=1;i<=n;++i) scanf("%d",&s

2016-10-17 20:29:07 385

转载 网络流算法

将每条有向边想象成传输物质的管道。每个管道都有一个固定的容量,可以看作是物质能流经该管道的最大速度(譬如可以想象为水流和河槽)。顶点是管道间的连接点,除了源点(S,Source)和汇点(T,Target)以外,物质只流经这些顶点。而不聚集在顶点中。     注:下文提到的数字,基本都可加单位 “单位流量”来理解。一、网络流基础     网络流中的最大流研究的问题是:在不违背

2016-10-15 18:47:20 585

原创 最大流模板

#include #include #include #include #include #define SIZE 220#define INF 1e8using namespace std;int maps[SIZE][SIZE];int flow[SIZE];int pre[SIZE];int n,m;queue q;int bfs(int src,int des

2016-10-10 15:52:08 295

原创 hdu5904LCIS(LCIS+DP)

各方聚聚们的“简单DP”、“水题”仿佛对我的一刀又一刀……就想问我为什么TLE那么多遍……代码在这:#include #include #include #include using namespace std;int a[1000005];int b[1000005];int f[1000005];int g[1000005];int as[1000005];

2016-09-26 19:00:22 417

原创 poj2485 Highways(最小生成树水题)

据说水的可以……于是用上道题的模板改了一下输入输出……代码跟上道题没有什么不同……代码:#include #include #include #include #include #define MAX 2000using namespace std;int map[510][510];int prim(int n){ int lowstep[MAX];

2016-09-24 17:13:27 527

原创 poj1789 Truck History(最小生成树Prim算法)

一个完全图的最小生成树算法,模板过……题意大概是给你n个长度为7的字符串,每个字符串之间不同的字符个数为两串之间的权值,求n个字符串的最小权值和代码在这:#include #include #include #include #include #define MAX 2000using namespace std;int dis(char s1[],char s2[])

2016-09-24 14:08:13 314

原创 hdu5898 odd-even number(数位DP)

比赛的时候虽然有说要用数位DP,但是看了看还是没有什么具体的思路,之后看到大神的思路觉得很腻害……代码在这;#include #include #include #define LL long longusing namespace std;LL dp[25][5];int num[25];LL dfs(int pos,int lit,int sts){ if(p

2016-09-23 22:32:17 332

原创 poj1094 Sorting it all out(拓扑排序)

这道题写的不好,很多错误,最后代码也不够好……题意就是求是否排序是否完全而且正确,可能会出现矛盾(也就是环)或者依然有字母不能确定,但是如果在前几次能够排完的话以后的输入就不需要判断了代码在这:#include #include #include #include #include using namespace std;int nmb[26];int map[26][

2016-09-23 22:24:32 343

转载 Meisell-Lehmer算法(大素数模板)

比赛的时候搜到了这个模板,居然没细看……看到其他博主有说还有更快的叫Deleglise Rivat的算法,并没有搜到……网上搜的模板:#include #include #include #include #include #define LL long longusing namespace std; const int N=5e6+2;bool np[N];int p

2016-09-20 15:28:00 1932

原创 poj 3259 Wormholes(最短路Bellman-Ford算法)

求负权图的单源最短路代码在这:#include #include #include using namespace std;struct node{ int x,y,d;}a[20010];int dis[50010];int n,m,w;int bellmanford(int n){ int x,y,d; for(int i=1;i<=n;

2016-08-24 15:08:24 341

原创 poj 2377 bad cowtractors(最大生成树模板水题)

这个题意虽然过程有些曲折(我仿佛看到了没有工资的人的恶意),反正结果就是要求一个最大生成树,模板套上就可以……代码在这:#include #include #include using namespace std;const int maxn=100010;int tree[maxn*2];struct node{ int x,y,d;}a[1500010];i

2016-08-23 08:29:19 373

原创 poj 1128 Frame Stacking(拓扑排序+DFS(递归))

1.记录每个出现的不同的字母的边界2.记录这个字母是否在原图中出现3.入度记录该字母是否覆盖了其他字母4.拓扑排序5.深搜时的递归记得回溯代码在这:#include #include #include #include #include #include using namespace std;struct node{ int x1,x2;

2016-08-19 15:17:13 337

原创 poj 3667 hotel (线段树+区间合并)

以前学习过的线段树,在查询和更新的基础上加入了区间合并,利用延迟标志来实现这一方法代码在这:#include #include #include using namespace std;const int N=50050;struct node{ int l,r; int mk; int ls,rs,ms;}tree[N*10];int n,m

2016-08-17 10:24:57 299

原创 poj1176 party lamps(dfs)

千辛万苦的用char型过了……代码在这:#include #include #include #include #include using namespace std;int n,c;int a[101];int op[101];int cl[101];char ss[300][110];int cmp(const void *p,const void *q){

2016-08-16 18:36:59 343

原创 poj 1018 Communication System(DP)

可能有很多方法吧,用的DP做的,其他的现在暂时不知道怎么用,枚举的是带宽,如果选择了价格来枚举的话,用的内存可能会更大而且一般是会TLE的代码在这:#include #include using namespace std;int dp[110][1100];int b[110][110];int p[110][110];int t,n;int m[110];

2016-08-16 15:20:29 343

原创 poj 2752 Seek the Name, Seek the Fame(kmp)

求相同前后缀的位数……代码在这:#include using namespace std;const int N=400010;char s[N];int x;int next[N],res[N];void fnext(){ int i,k; int n=strlen(s); next[0]=-1; for(i=1,k=-1;i<n;++

2016-08-13 15:24:31 264

原创 poj 3461 Oulipo(简单的kmp入门)

就是完完全全用kmp算法来写的一道题,每当找到一个与模式串匹配的计下次数,然后以next数组后退继续寻找下一个代码在这:#include #include #include using namespace std;const int N=1000010;char s[N];char p[N];int next[N];void fnext(){ int i,k

2016-08-13 10:31:16 267

转载 字符串匹配算法总结

转自:http://blog.csdn.net/zdl1016/archive/2009/10/11/4654061.aspx 我想说一句“我日,我讨厌KMP!”。KMP虽然经典,但是理解起来极其复杂,好不容易理解好了,便起码来巨麻烦!老子就是今天图书馆在写了几个小时才勉强写了一个有bug的、效率不高的KMP,特别是计算next数组的部分。其实,比KMP算法速度快的

2016-08-11 09:07:35 490

原创 hdu 3652 B-number(数位dp)

总结一下我在这道题上的失误真心想打死自己1.数组开的过小还沾沾自喜2.细节方面经常有数据上的错误(啊!!!!!!!!!!!好愤怒啊!!!!!!再出这种事我!!先不立flag了!!!!反正很想捅死自己啊!!)3边界很重要边界很重要边界很重要写完这道题我真的是森森的恨自己……可能会抑郁一个周……代码在这:#include using namespace std;i

2016-08-08 19:50:24 295

原创 HDU 2089 不要62(数位DP)

发现动归是个深坑……一个数位dp入门……觉得动态规划真的是有很大的灵活性呀~~数据的初始化也很重要~代码在这:#include #include #include #include using namespace std;int dp[10][10];void init(){ memset(dp,0,sizeof(dp)); dp[0][0]=

2016-08-08 10:07:43 228

原创 poj1185炮兵阵地(状态压缩DP)

状态压缩就是利用各种进制(基本是二进制)来保存一个状态,在这种图中应用起来也很方便,这道题我觉得有点烦,看了这位大神的详细讲解之后,才算明白地比较彻底,明白之后觉得这道题只是有一点复杂,思路还是很清晰的代码在这:#include #define max(a,b) a>b?a:b#define cl(a) memset(a,0,sizeof(a))#define q(a,

2016-08-03 11:54:23 294

原创 codevs 1124线段覆盖(贪心)

用贪心的算法算,从最左端开始,所以在计算之前要排一下序,一旦遇到这一段的左端点小于上一段的右端点,这段就去掉,还有,这种线段的描述用pair非常方便,记得以前什么时候翁聚曾经给普及过这个,详细介绍:c++之pair代码在这:#include using namespace std;int main(){ pairp[1010]; int n; s

2016-08-01 17:50:00 329

原创 HDU 1251 统计难题(字典数)

一个很典型的字典数题,不需要什么技巧模板就可以过,但是我在做这道题时出现一个状况,可以说也是学到了吧O(∩_∩)O因为我是在linux下写的这道题,在字符串输入时一直选择了gets()函数,但是linux下的gcc好像不支持这个函数,上网搜了几个解决办法:1 下载一个readliine-dev包2 自己写一个readline.h的头文件3 改用fgets函数,fgets函数跟get

2016-07-30 14:14:45 320

原创 poj 3311 Hie with the Pie(状态压缩DP+floyd)

题意是求穿过n个城市后返回的最短路程,n为城市数,一个n*n的数组,第i行第j列表示从i城市到j城市中间不经过其他城市所需的路程,所以要先求最短路,然后根据此时的状态i求出到j城市所需的最短路程,返回时直接返回这个的状态需要用二进制表示,容易出错代码在这:#include #include #include #include using namespace std;int

2016-07-29 16:56:21 332

原创 QUSTOJ1782 A奶牛的锻炼(线性动归)

这道题我使用的是一维数组,虽然样例能过,但提交后没有AC,肯定有些地方我处理的不够好,但是用二维数组写起来就方便很多……二维数组f[i][j]代表前j分钟疲劳值为j时的最大步数,在第i分钟时,奶牛可以跑或者休息,跑的话f[i][j]=f[i-1][j-1]+s[i](当前i分钟时跑步的步数);如果休息那么f[i][j]等于在它之前的疲劳值相差不超过m的一次最大步数即f[i-k][k]当疲劳

2016-07-23 16:11:22 438

原创 QUSTOJ1784 C 机器分配(DP)

题目给出矩阵是s[i][j]代表第i个公司分配j台机器的收益,因此可以设f[i][j]为i个公司分配j台机器的最大总收益,枚举k,f[i][j]可以取i-1个公司分配k台机器的最大受益加上第i个公司分配j-k台机器的和的最大值。这不是区间动归??……这是代码:#include using namespace std;int m,n,s[1001][1001],f[1001]

2016-07-23 15:51:23 387

原创 vjP1955货币(记忆化搜索)

又是一道水题,但数据量是个问题啊( ⊙o⊙ )#include #define ll long longusing namespace std;long long n;long long f[50000100]={0};long long dp(long long k){ if(k<6) return k; if(k<=50000099&&f[k]!=0) re

2016-07-22 13:42:47 357

原创 vj P1547 逆转,然后再见(记忆化搜索)

水题#include using namespace std;int s[110][110]={0};int n;struct NODE{ int value; int flag;}node[110];int minn=1e6;int FLAG=0;int sum=0;void bfs(int k){ if(sum<minn&&FLAG==(n

2016-07-22 13:40:36 455

原创 DP1线性动态规划4题.

例4 LCS(最长公共子序列)一个给定序列的子序列是在该序列中删去若干元素后得到的序列。确切地说,若给定序列X=是X的子序列,是指存在一个严格递增的下标序列例如,序列Z=是序列X=的子序列,相应的递增下标序列为。给定两个序列X和Y,当另一序列Z既是X的子序列又是Y的子序列时,称Z是序列X和Y的公共子序列。例如,若X=和Y=,则序列是X和Y的一个公共子序列,序列也是X和Y的一个公共子

2016-07-22 13:34:34 1370

原创 Codeforces #361 D Mike and Chocolate Thieves(二分+数学)

题意大体是有四个小偷去偷巧克力,四个人偷巧克力的个数是一个等比数列,输入四个小偷可能的n种方案,输出最小的符合这个方案的所有等比数列的最大值这道题自己在二分的时候老是遇到浮点数的报错问题,千辛万苦的改加上看了很多网络上的正确代码,改对(坚强的微笑)……这是代码:#include using namespace std;long long l=1,r=1e18;long lon

2016-07-20 18:54:46 465

原创 Codeforces #361 (Div. 2)B-Mike and Shortcuts(spfa最短路)

大意是给你n个城市,从i到i+1个城市需要1能量,但又快捷路径可走,给出n个数,第i个数表示从i城市到这个数代表的城市只需1能量,求从1到n所需的最小能量 -_-用spfa和Dijkstra应该是都可以,在老师的建议下我使用了spfa算法由于问题中大数据的问题,从网上找到很多提高代码效率的东西和方法,感觉学到了也(*^__^*)一个是inline定义类的内联函数,对宏定义的提升(??)

2016-07-20 16:35:52 547

原创 poj1179-polygon(动态规划)

动归这个算法还是很明显的,首先先对输入的所有操作数和操作符进行保存,第一步,删掉一条边,这个循环遍历,然后接下来的n-1条边每条边和其两个顶点进行删除根据边进行运算将值传递到代替他们的新顶点上,知道所有的边被删除完,剩下的值就是最大值。#include #include #include using namespace std;const int maxlen=51;const i

2016-06-14 15:07:38 573

转载 record

经典训练参照,不解释了,很好~1.图论2.数据结构3.搜索4.动态规划5.模拟6.数学7.计算几何8.博弈论9.字符串=========================================初期:一.基本算法:(1)枚举. (poj1753,poj2965)(2)贪心(poj1328,poj2109,poj2586)(3)递归和

2016-06-02 18:01:14 505

原创 poj1178Camelot(floyd最短路算法+枚举)

因为是8×8的方格,所以枚举终点位以及亚瑟王与骑士相遇的相遇位,floyd求一下最短路,最后去一下那个遇到亚瑟王的骑士的重复步数。恩……刚开始没有思路……用DP没有做出来……(╯﹏╰)然后看了其他用枚举的思路……(づ。◕‿‿◕。)づ我会好好记住的!!#include #include #include #include using namespace std;int km

2016-05-31 17:41:53 522

原创 poj1163The Triangle(DP)

额,不管怎么说,算得上是一道比较经典的dp了吧……(⊙o⊙)代码也很简单……想想还是放上来吧……#include #include #include using namespace std;int s[110][110];int dp[110][110];int main(){ int n; scanf("%d",&n); for(int i=1;i<=n;+

2016-05-29 20:21:37 317

原创 poj1157LITTLE SHOP OF FLOWERS(简单DP)

比较水,比较值得注意的是当花瓶数多于花束时,要判断第i束花是放在第j个花瓶中更具美观值还是不放在第j个花瓶中更具美观值,其实,也没有多少要说的……(● ̄(エ) ̄●) 每天一水题,好歹提升一下信心……#include #include #include using namespace std;int w[110][110];int dp[110][110]={0};

2016-05-29 14:48:19 302

空空如也

空空如也

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

TA关注的人

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