自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

yhf_2015

Holle World.

  • 博客(20)
  • 资源 (2)
  • 收藏
  • 关注

原创 【poj 3250】 Bad Hair Day

单调栈#include #include using namespace std;long long n, a1[80010], p1[80010], p, ans;int main(){ scanf("%lld", &n); for(int i = 1; i <= n; i ++) scanf("%lld", &a1[i]); a1[++n] = 1e9+10; f

2016-09-29 11:20:20 277

原创 【bzoj 3670】 [Noi2014]动物园 KMP变式

num数组让记录前缀后缀相同且不重复的数的个数,因为有限制条件,前后不能重复,所以匹配的时候如果有重复的也算是匹配失败。然后是记录方案,考虑#include using namespace std;const int mod = 1e9+7;int n, m;char a1[1000010];int f[1000010], num[1000010];inline

2016-09-27 19:13:40 318

原创 【hdu 2203】 亲和串 KMP匹配

处理环的方法:把链上的元素向后复制一遍。#include using namespace std;char a1[200010], b1[100010];int f[100010];int main(){ while(scanf("%s%s", a1+1, b1+1) != EOF){ int len1 = strlen(a1+1)*2, len2 = strlen(b1+1);

2016-09-27 12:45:48 203

原创 【hdu 3746】 Cyclic Nacklace KMP求循环节

考虑循环节的产生,产生一个循环节,一定是后面的f数组单调递增,全部可以完全匹配。所以总长度减去递增的长度就是循环节的长度。#include using namespace std;char ch[100010];int f[100010];int main(){ int t; scanf("%d", &t); while(t --){ scanf("%s", ch+1

2016-09-27 11:27:30 203

原创 读入优化模板

读入优化模板。inline int gt(){ char _ch; int _num = 0, _op = 1, _ok = 0; while(_ch = getchar()) if(_ch == '-') _op *= -1; else if(_ch >= '0' && _ch <= '9') _num = _num*10 + _ch - '0', _ok = 1; els

2016-09-27 09:01:19 272

原创 【hdu 2087】 剪花布条

每次匹配成功,将p清零。#include using namespace std;char a1[1010], b1[1010], f[1010];int main(){ while(scanf("%s", a1+1) && a1[1] != '#'){ scanf("%s", b1+1); int len1 = strlen(a1+1), len

2016-09-27 07:57:48 194

原创 【hdu 1711】 Number Sequence KMP模板

#include using namespace std;int t, n, m;int a1[1000010], b1[10010], f[10010];bool flag;inline int gt(){ char _ch; bool _ok = 0; int _num = 0, _op = 1; while(1){ _ch = getchar(); if(_ch =

2016-09-27 07:29:07 207

原创 【vijos 1029】晴天小猪历险记之Number

额,用的暴力,康托展开都没写,暴力hash水过。#include using namespace std;typedef long long ll;const int mod = 1999183;bool map1[mod];struct node{ int num, step;};bool ok;int ch[15];int b1[20] = {0,2,2,2,4

2016-09-23 07:35:50 704

原创 【vijos 1107】 环游大同80天

就相当于求树的直径。#include using namespace std;int b1[5] = {0,0,0,1,-1};int b2[5] = {0,1,-1,0,0};bool vis[1010][1010];char a1[1010][1010];int ans = 0, maxx = 0, maxy = 0, max1 = 0;int dfs(int x,

2016-09-23 07:31:08 567

原创 【CF 125D】 Two progressions 划分等差数列

翻译:有一个整数序列a[],你需要将它划分成两个非空序列,满足两个序列都是等差数列。"等差数列"定义为相邻两项间差值相等的非空序列;特别地,长度为1或2的序列也是等差数列,但长度为0的不是(因为必须非空)。"划分"定义为,将原序列中的所有元素分成两个序列,满足每个元素都在恰好一个序列中,且保留其在原序列中的顺序。例如[1, 3, 4]和[2, 5]就是[1, 2, 3, 4, 5]的一个划分,[1

2016-09-23 00:59:27 536

原创 【vijos 1659】 河蟹王国

线段树裸题。注意:更新的操作一定要在修改之后再进行,否则最大值变小后无法更新。#include using namespace std;#define mid ((l+r)>>1)#define lch (now<<1)#define rch ((now<<1)+1)#define fa (now>>1)const int maxn = 100010;typedef

2016-09-21 21:24:55 329

原创 【CF 125C】 Hobbits' Party

翻译: 小L要举办一场派对,他有n个朋友可以邀请来参加。派对会持续若干天,为了保证每个人都能玩得开心,小L希望,对于这若干天中的任意两天,都存在某个人参加了这两天的派对;而为了保证朋友们不会觉得他偏心,对于任意三天,都不存在某个人参加了所有这三天的派对。求小L最多能举办多少天派对。 3 输入格式:一行,一个正整数n。输出格式:第一行输出一个整数k,表示派对最多能举行的天数。接下来k行,第i

2016-09-21 21:20:06 471

原创 【洛谷 2839】 畅通工程

并查集基础题,适合初学者练习。#include using namespace std;int fa[1010], ans;bool vis[1010];int find(int x){ return fa[x] == x ? x : fa[x] = find(fa[x]);}int main(){ int n, m; scanf("%d%d", &n, &m);

2016-09-21 15:08:25 252

原创 【洛谷 1032】 字串变换

很好的bfs的题,实现写的比较麻烦,但感觉不错,思路很清晰,适合考试。#include using namespace std;int cnt=1;bool flag=0;string a, b;string d[10][2];struct node{ string a; int step;};queue q1;map map1;bool bfs(){ q1.

2016-09-21 09:12:21 621

原创 【洛谷 1542】 包裹快递

本来是一道很好的二分答案的题,结果不知道是数据还是评测机,交了20多次,都被卡了精度……后来受不了了,直接复制了一份原来别人A过的程序,结果还是wa那一个点,果断放弃,打表。#include using namespace std;int f[200010], t[200010], d[200010], n;bool pd(double mid){ double time

2016-09-21 00:49:37 555

原创 【洛谷 1483】 序列变换

要考虑完全平方数的情况,注意因子的取值关系。#include using namespace std;long long a1[1000010], d[1000010];int n, m;int main(){ scanf("%d%d", &n, &m); for(int i = 1; i <= n; i ++) scanf("%lld", &a1[i]

2016-09-20 07:34:10 355

原创 【洛谷 2341】 [HAOI2006]受欢迎的牛

有空多打几遍,多熟悉一下。#include using namespace std;const int maxn = 10010;const int maxm = 50010;int n, m;int _first[maxn], _next[maxm], _to[maxm], _cnt;int out[maxn], num[maxm], belong[maxm], _num;in

2016-09-20 07:28:47 246

原创 【洛谷 1186】 玛丽卡

又是开错了数组……要记住。

2016-09-19 22:51:15 401

原创 【poj 2264】 Advanced Fruits

题解:最长公共子序列+路径记录设dp[i][j]经典转移,用path[i][j]记录路径,记录公共序列出现的位置,倒着向前找,如果有字符相同并且dp[i][j]是从dp[i-1][j-1]转移过来的,那么这就一定是公共子序列的一部分,记录后输出剩余的部分即可。#include #include #include #include #include using namesp

2016-09-03 15:02:05 245

原创 【poj 1947】 Rebuilding Roads

分类:树形dp题解:设dp[i][j]为以i为根的子树中分离出j个点的最小代价树形dp解题时,一般用子树的信息来更新根,先用dfs搜索,按dfs的顺序从下向上搜索。#include #include #include #include using namespace std;const int maxn = 210;int _first[maxn], _next[maxn]

2016-09-03 14:24:37 204

sdoi2017R1D2

sdoi2017R1D2

2017-04-16

sdoi2017R1D1

sdoi2017R1D1

2017-04-16

空空如也

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

TA关注的人

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