自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

满月照亮的路

如果命运是风,什么又是我的绳?

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

原创 CodeForces 407B Long Path (Dp+思维)

#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long long#define lrt int l,int r,int rt#define lson l...

2019-05-30 11:12:48 87

原创 2019 西安邀请赛 And And And(计数+树形DP)

题目链接:https://www.jisuanke.com/contest/2625#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long long#...

2019-05-26 19:52:47 205

原创 CodeForces 888D Almost Identity Permutations (组合数学)

#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long long#define lrt int l,int r,int rt#define lson ...

2019-05-19 06:27:28 198

原创 CodeForces 180C Letter (水)

#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<=(z);(x)++)#define per(x,y,z) for(int (x)=(y);(x)>=(z);(x)--)#define ll ...

2019-05-19 06:24:49 263

原创 CodeForces 933A A Twisty Movement (DP)

#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<=(z);(x)++)#define per(x,y,z) for(int (x)=(y);(x)>=(z);(x)--)#define ll ...

2019-05-19 06:23:15 205

原创 CodeForces 459E Pashmak and Graph (图论+DP)

#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long long#define lrt int l,int r,int rt#define lson l...

2019-05-19 06:20:45 156

原创 CodeForces 478D Red-Green Towers (DP+优化状态)

很容易想到二维DP暴力吧,但是题目不允许,于是开二维dp(i,j)表示堆到i层且r用了j个的方案数,如果i*(i+1)/2<=g+j,dp(i,j)+=dp(i-1,j);表示这层如果不放r的话如果j大于等于i,dp(i,j)+=dp(i-1,j-i);那么压缩下空间应该不难,初始化dp(0)=1#include<bits/stdc++.h>using...

2019-05-15 17:08:39 198

原创 HDU 6146 Pokémon GO (组合数学+DP)

需要用dp的思想去找状态,我们先维护出从一端开始的情况,还是可以分成两种情况,一种是回到原来位置,另一种是不是,很明显要想最后回到原来位置,每次都要往前步进,计数为2的长度幂次,下面就是不回到原点了,一种是直接下一步把当前位置再走掉然后状态这里就开始切分,得到了一个F(n-1),其中F函数其实就是我们本来在维护的含义,即f(n,0)+f(n,1).那么可以得出:f(n,1)=2*(f(n...

2019-05-14 12:08:29 134

原创 HYSBZ 1008 越狱 (组合数学+DP)

考虑前两个,如果两个一样,那么就是m^(n-1),不一样的话就是f(n-1),式子:f(n)=f(n-1)*(m-1)+m^(n-1),不难凑出:(f(n)-m^n)=(f(n-1)-m^(n-1))(m-1).f(2)为m.#include<bits/stdc++.h>using namespace std;#define debug puts("YES"...

2019-05-12 19:39:25 142

原创 HDU 5894 hannnnah_j’s Biological Test (组合数学)

题目大意给定n,m,k,表示有n个桌子,m个人,每个人之间相距不小于k,问这样组合的方案数.题目分析因为是圆形的排布,我们先选定一个起点,即指定一个位置放人,我们现在可以把一个人和下面k个空位当成一个,那么剩下的就是m-1个人和n-k*m-1个空位可供选择,直接组合数C(n-m*k-1,m-1)来选择即可.我们可以对任何一个位置这样做,所以要乘上n,...

2019-05-11 19:14:43 227

原创 Codeforces Round #554 (Div. 2) (A,B,C)

题目链接:http://codeforces.com/contest/1152第一题(模拟)#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long l...

2019-05-11 18:57:14 149

原创 南昌邀请赛网络赛 Distance on the tree (主席树+动态倍增LCA)

题目链接:https://nanti.jisuanke.com/t/38229考研ing,题解比较随意题目大意给定一棵树,有边权,每次查询问u,v路径上权值不大于k的个数是多少.题目分析主席树,每个点记录是所有祖先节点记录的前缀和,那么对于主席树来讲前后关系就明显了.再套个动态倍增LCA,就可以做了.详见代码#include<bits/stdc++...

2019-05-10 21:04:12 171

原创 CodeForces 710E Generate a String (DP)

分奇偶讨论,注意奇数时候可以往上一位再除二#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long long#define lrt int l,in...

2019-05-10 14:04:27 120

原创 CodeForces 255C Almost Arithmetical Progression (DP+离散化)

发现规律序列为a,b,a,b,a,b即可.#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long long#define lrt int l,in...

2019-05-09 22:39:41 133

原创 Codeforces Round #555 (Div. 3) (A,B,C1,C2,D,E,F)

题目链接:http://codeforces.com/contest/1157第一题#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long long...

2019-05-08 07:14:39 104

原创 CodeForces 630G Challenge Pennants (组合数学+DP)

暴力DP过的,题意有点迷,反正看了题解的翻译意思是n个桌子5个a类气球3个b类气球问读诵好中摆放方式.#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll l...

2019-05-07 20:22:40 167

原创 CodeForces 630H Benches (组合计数)

题目链接:http://codeforces.com/problemset/problem/630/H#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll lon...

2019-05-07 17:25:43 133

原创 CodeForces 630I Parking Lot (组合计数)

题目链接:http://codeforces.com/problemset/problem/630/I#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll lon...

2019-05-07 17:24:21 260

原创 POJ 2800 Joseph's Problem (数论分块)

最后是要求sigma k%i,i从1到n,转换为k-k/i*i,明显这个东西可以分块求,时间复杂度是根号级别的,即从i到k/(k/i)这个区间所对应的k/i都是一样的,然后变化的是i部分可以等差数列求和O(1)得出.#include<iostream>#include<cmath>#include<algorithm>using ...

2019-05-07 07:18:18 178

原创 CodeForces 219D Choosing Capital for Treeland (树形DP)

#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long long#define lrt int l,int r,int rt#define lson l...

2019-05-05 13:06:11 140

原创 CodeForces 687C The Values You Can Make (01背包二维容量空间)

题目大意给定一个序列,和一个k,如果有个子集和可以组成k,那么把子集中所有的可以通过这个子集可表示出来的数数出来,按序.题目分析这道题我是没想到的.....考虑把每个序列的一个数当成背包来影响目标空间,那么思考如何构造这个目标空间.一个数能否被得到,要取决与是否有子集可以通过普通dp的方式得到.令dp(i,j)表示,组成i的子集是否可以组成j.那...

2019-05-05 13:05:21 94

原创 CodeForces 479E Riding in a Lift (优化DP,打标记+前缀和)

主要是往下更新下一层DP的时候要用到前缀和的思想打标记.#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long long#define lrt i...

2019-05-05 12:57:00 182

原创 CodeForces 463D Gargari and Permutations (DFS建图+DP)

主要是需要建图,i和j是否可以连边需要比较i的位置是不是每个序列都出现在j的前面,想清楚这点就简单了.#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll l...

2019-05-05 12:54:59 137

原创 CodeForces 873B Balanced Substring (预处理)

把0当成-1预处理所有前缀和即可#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long long#define lrt int l,int r,i...

2019-05-03 07:15:31 155

原创 luogu3369 普通平衡树(平衡树模板题)

题目链接:https://www.luogu.org/problemnew/show/P3369#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long l...

2019-05-02 09:15:12 139

原创 HDU 6513 Reverse It(组合数学+消去重复度)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6513题目大意给定一个01矩阵,现在可以选择至多两个子矩阵把值进行转换(0-1,1-0),问能产生总共多少种不同的花纹数.题目分析首先考虑两个子矩阵和一个子矩阵,不难发现一个子矩阵就是:C(n+1,2)*C(m+1,2),因为n个长度其格点有n+1个.而两个子...

2019-05-01 23:09:23 286

原创 Codeforces 1155D Beautiful Array(子段和+DP)

题目链接:http://codeforces.com/problemset/problem/1155/D题目大意给定一个序列,和一个数字k,现在可以允许把一段连续的子列数字均乘上k,或者不操作,问可以得到的最大子段和是多少.题目分析最大子段和的变种吧,分析决策状态都在什么大体情况下产生,或者分析候选答案的集体特征吧,我们分析三种状态,dp(i,j),...

2019-05-01 22:27:54 180

原创 Codeforces Round #552 (Div. 3)G Minimum Possible LCM (数论+优化枚举状态)

题目链接:http://codeforces.com/contest/1154题目大意给定一序列数,问其中两个数的lcm最小值是多少.题目分析这道题大致就是我最近一直想着的优化决策问题,或者说是优化枚举状态问题,所有答案候选集合明显过大了,要想办法优化,我们可以把每个数都丢到其所有因子的桶中试试看,如果对于同一个因子,有若干个数根据贪心的思想我们只要把前...

2019-05-01 22:21:19 149

原创 Codeforces Round #552 (Div. 3)F Shovels Shop (前缀和+背包DP)

题目链接:http://codeforces.com/contest/1154题目大意给定n个东西的价值,有m种优惠方式,每种是个二元组,表示恰好买x个数可以免费y个最便宜的,问恰好买k个物品的最小花费是多少.题目分析由于k数据范围很小,我们从k这个维度思考.首先贪心的把商品按价值排序,然后把每种决策用一维数组映射出来,明显对于一样的x我们选y最...

2019-05-01 22:15:19 130

原创 Codeforces Round #552 (Div. 3) E Two Teams (链表模拟)

题目链接:http://codeforces.com/contest/1154题目大意给定一个序列,每次老师把序列中的最大值及其附近的k个人(如果不足则割舍)加到他的阵营,总共有两名老师轮番做这个操作,输出一个序列表示每个人都在哪个阵营.题目分析k和n的数量级都是五次方,很迷惑人,其实不难发现每个数只会被用到一次,那么我们不妨用链表来跳跃性的映射关系,初...

2019-05-01 22:08:34 121

空空如也

空空如也

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

TA关注的人

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