<?xml version="1.0" encoding="utf-8" ?><rss version="2.0"><channel><title><![CDATA[Masamiiiiii]]></title><description><![CDATA[]]></description><link>https://blog.csdn.net/Jeremy1149</link><language>zh-cn</language><generator>https://blog.csdn.net/</generator><copyright><![CDATA[Copyright &copy; Jeremy1149]]></copyright><item><title><![CDATA[Codeforces 679C Bear and Square Grid 暴力(滑动窗口)]]></title><link>https://blog.csdn.net/Jeremy1149/article/details/77366929</link><guid>https://blog.csdn.net/Jeremy1149/article/details/77366929</guid><author>Jeremy1149</author><pubDate>Fri, 18 Aug 2017 10:57:11 +0800</pubDate><description><![CDATA[题意:n*n地图,'X'为障碍,'.'可以到达四周相邻的'.'
现在给你一次机会:选择某个k*k子矩形将里面'X'变为'.'
n,k

暴力枚举变化子矩形的左上角,判断和该子矩形连通有哪些联通分量.
只要检查子矩形的4个边界即可.O(n^2*k)
k*k中可能有和外部相连的联通分量,先加上k*k,然后在内部减小这些连通分量大小,防止重复计算.滑动窗口处理即可.
#include 
u]]></description><category></category></item><item><title><![CDATA[Codeforces 677D Vanya and Treasure BFS+DP (分段)]]></title><link>https://blog.csdn.net/Jeremy1149/article/details/77337117</link><guid>https://blog.csdn.net/Jeremy1149/article/details/77337117</guid><author>Jeremy1149</author><pubDate>Thu, 17 Aug 2017 17:43:37 +0800</pubDate><description><![CDATA[题意:n*m地图,保证至少有一个点为a[i][j]=x (x=[1..p]),两点花费为:欧几里得距离.
n,m

设f[i][j] 从起点到(i,j)(1-a[i][j]已经拿完)的最小花费.
相邻两组数量都很大时,转移最坏情况O((nm)^2)
cnt[x]*cnt[x+1]>=n*m,最多sqrt对,bfs暴力更新
sum(cnt[x]*cnt[x+1]
#include 
u]]></description><category></category></item><item><title><![CDATA[Codeforces 703E Mishka and Divisors 离散化+DP]]></title><link>https://blog.csdn.net/Jeremy1149/article/details/77198079</link><guid>https://blog.csdn.net/Jeremy1149/article/details/77198079</guid><author>Jeremy1149</author><pubDate>Tue, 15 Aug 2017 17:59:29 +0800</pubDate><description><![CDATA[题意:给出长度为n的序列a,子序列合法：子序列中每个元素相乘后得到的乘积能被k整除
n
 
设f[i][d]为 前i个数中选出乘积为d的倍数需要的最少个数.
f[i][d]=min(f[i-1][d],f[i-1][d/gcd(d,a[i])]+1)  (f[i][x]
离散化第二维,因为d每次都转移到自己的某个因子中.最坏情况下只有6720个因子..
#include 
using]]></description><category></category></item><item><title><![CDATA[Codeforecs 675E Trains and Statistic 贪心+DP]]></title><link>https://blog.csdn.net/Jeremy1149/article/details/77164932</link><guid>https://blog.csdn.net/Jeremy1149/article/details/77164932</guid><author>Jeremy1149</author><pubDate>Mon, 14 Aug 2017 18:33:58 +0800</pubDate><description><![CDATA[题意:给出n-1个数,a[i]表示: 从i能直接到达点[i+1,a[i]].p[i][j]为i->j的最短路径.
n

考虑从i出发[i+1,a[i]]这段只需要1,[a[i]+1,max(a[i+1],a[i+2],a[a[i]])]这段最短距离为2
a[m]=max(a[i+1],a[i+2],a[a[i]],也就是说若移动次数大于1,第一步肯定移动到m点(m点的下一次选择最多)
设]]></description><category></category></item><item><title><![CDATA[Codeforces 713C Sonya and Problem Wihtout a Legend DP(经典)]]></title><link>https://blog.csdn.net/Jeremy1149/article/details/77102513</link><guid>https://blog.csdn.net/Jeremy1149/article/details/77102513</guid><author>Jeremy1149</author><pubDate>Fri, 11 Aug 2017 19:43:46 +0800</pubDate><description><![CDATA[题意:给出长度为n的序列a,op:将任意一个数增大/减小1.
n


当a递增时:a[i]
也就是b[i]=a[i]-i非递减.同样b非递减时,a也就是递增的.转为求使b非递减最小代价
序列b非递减,则最后b中元素都为原来的某些元素,假如x!=b[k] 则通过逆操作把x变为相邻某个b[k] 操作减少,单调性不变.设dp[i][j]:前i个元素变非递减,第i个元素为原来第j大时的最小代价]]></description><category></category></item><item><title><![CDATA[Codeforces 705D Ant Man DP(贡献)]]></title><link>https://blog.csdn.net/Jeremy1149/article/details/77019036</link><guid>https://blog.csdn.net/Jeremy1149/article/details/77019036</guid><author>Jeremy1149</author><pubDate>Fri, 11 Aug 2017 01:31:17 +0800</pubDate><description><![CDATA[#include 
using namespace std;
typedef long long ll;
const int N=5e3+5;
const ll inf=2e16;
int n,s,t,x[N],a[N],b[N],c[N],d[N];
ll dp[N][N];
ll solve(int i,int j,int k)
{
	if(i==n)
	{
		if(j==0&&k==0)]]></description><category></category></item><item><title><![CDATA[Codeforces 707D Persistent Bookcase 暴力(bitset)]]></title><link>https://blog.csdn.net/Jeremy1149/article/details/77075559</link><guid>https://blog.csdn.net/Jeremy1149/article/details/77075559</guid><author>Jeremy1149</author><pubDate>Fri, 11 Aug 2017 01:26:06 +0800</pubDate><description><![CDATA[题意:书房有n个架子,每个架子有m层.q次操作.
op1:第i个架子的第j层放一本书, op2:拿走第i个架子的第j层上的书.
op3:反转第i个架子:将第i个架子中有书的拿走,没书的放书.op4:把书房恢复到第k次操作后的状态.
n,m


离线:因为每次暴力更新加上bitset优化区间翻转后复杂度为O(mq/32).则把每个op看成图中的结点.
第i次若进行op4则将i连到x结点]]></description><category></category></item><item><title><![CDATA[Codeforecs 705C Working Routine 模拟(链表)]]></title><link>https://blog.csdn.net/Jeremy1149/article/details/76943843</link><guid>https://blog.csdn.net/Jeremy1149/article/details/76943843</guid><author>Jeremy1149</author><pubDate>Tue, 08 Aug 2017 20:48:05 +0800</pubDate><description><![CDATA[题意:n*m矩阵,q次操作,每次给出两个矩形的左上角坐标,及宽度和高度.交换这两个不相交的矩形.
n,m
题意限制的很紧,一条直线上不会有属于不同矩形的格子.
每个格子存其右边和下面元素,交换两个子矩形不改变其内部指针,变得只有其四周一圈的指针O(q*(n+m))
#include 
using namespace std;
typedef long long ll;
const int ]]></description><category></category></item><item><title><![CDATA[Codeforecs 700D  Connecting Universities 构造]]></title><link>https://blog.csdn.net/Jeremy1149/article/details/76865242</link><guid>https://blog.csdn.net/Jeremy1149/article/details/76865242</guid><author>Jeremy1149</author><pubDate>Tue, 08 Aug 2017 09:05:08 +0800</pubDate><description><![CDATA[题意:n个结点的树,其中有2k个标记点,每个点只能配对一次,将标记点配对后,每问k对标记点距离累加和最大为多少?,n,k
首先一条边u-v的贡献最多为min(sz[v],2*k-sz[v).其次每条边都能达到这个上限.
从深度大的边开始check,假如存在u-v小于上限,则说明以v为子树中,至少有一个配对点(a,b).v之外的子树中有配对点(c,d）.将(a,c),(b,d)配对,贡献增加.当]]></description><category></category></item><item><title><![CDATA[Codeforces 698C LRU 概率+状压]]></title><link>https://blog.csdn.net/Jeremy1149/article/details/76849771</link><guid>https://blog.csdn.net/Jeremy1149/article/details/76849771</guid><author>Jeremy1149</author><pubDate>Mon, 07 Aug 2017 15:38:39 +0800</pubDate><description><![CDATA[题意:有一个箱子最多装k件物品,现在有n件物品,第i件物品被询问的概率为pi,当第i件物品被询问时,如果第i件物品不在箱子里面,则把第i件物品加入到箱子中,若箱子物品数量>k,则移除最早添加进来的物品.
问10^100次查询后,每个物品在箱子中的概率? n,k


询问10^100次,物品最多只有20个,所以可以说箱子最后肯定有k个物品
问题转化为求最后状态为S的概率,初始时抽到k种不同]]></description><category></category></item><item><title><![CDATA[Codeforces 696C PLEASE 概率(推公式)]]></title><link>https://blog.csdn.net/Jeremy1149/article/details/76762615</link><guid>https://blog.csdn.net/Jeremy1149/article/details/76762615</guid><author>Jeremy1149</author><pubDate>Sun, 06 Aug 2017 12:10:23 +0800</pubDate><description><![CDATA[题意:3个杯子,中间杯子放着炸弹.每一轮从左/右选一个杯子和中间杯子交换(等概率).
问n轮后,中间杯子有炸弹的概率? n=a[1]*a[2]..a[k] k
第i轮要想在中间则第i-1轮一定不能再中间 所以设dp[i]:i轮后在中间的概率.
dp[i]=(1-dp[i-1])*0.5 a[i]
因为最后答案要写成分数形式p/q.发现q每次都增大2.


dp[i]=(1-dp[i-]]></description><category></category></item><item><title><![CDATA[Codeforces 689E  Mike and Geometry Problem 思维]]></title><link>https://blog.csdn.net/Jeremy1149/article/details/76705178</link><guid>https://blog.csdn.net/Jeremy1149/article/details/76705178</guid><author>Jeremy1149</author><pubDate>Sat, 05 Aug 2017 10:15:35 +0800</pubDate><description><![CDATA[题意:n条线段[li,ri],f[l,r]为线段[l,r]的长度,问任意k条线段交集长度的累加和?
n,k
若点p被m条线段覆盖,则对答案贡献C(m,k),点的数量很多,转为计算f[i]:正好被i条线段覆盖的点有多少个?
答案为:f[i]*C(i,k)(i=k..n),端点最多2n个,利用前缀差分.一段一段算即可(同一段中的点被覆盖次数相同)
#include 
using namespa]]></description><category></category></item><item><title><![CDATA[Codeforces 687C  The Values You Can Make DP]]></title><link>https://blog.csdn.net/Jeremy1149/article/details/76651132</link><guid>https://blog.csdn.net/Jeremy1149/article/details/76651132</guid><author>Jeremy1149</author><pubDate>Thu, 03 Aug 2017 21:25:34 +0800</pubDate><description><![CDATA[题意:全集A为n个a[i],若有某个集合B其和为k,则B的任意一个子集C定义其元素之和x为合法
n,k,c[i]
设dp[i][j][k] 表示前i个数能凑出子集和为j,和为j的集合又有子集和为k
考虑第i个数是否加入,加入到集合j时,又分是否加入集合j的子集.
dp[i][j][k]|=dp[i-1][j][k]|dp[i-1][j-a[i][k]|dp[i-1][j-a[i]][k-a]]></description><category></category></item><item><title><![CDATA[Codeforces 651E Table Compression 拓扑序]]></title><link>https://blog.csdn.net/Jeremy1149/article/details/76598966</link><guid>https://blog.csdn.net/Jeremy1149/article/details/76598966</guid><author>Jeremy1149</author><pubDate>Wed, 02 Aug 2017 21:43:44 +0800</pubDate><description><![CDATA[题意:给出n*m矩阵a,要求把矩阵a压缩成矩阵b.b的元素尽量小.并且满足下列条件
若a[i][j]
若a[i][j]
 1

a[i][j]和其同行同列有着拓扑序,则从a[i][j]最小的开始填,每次维护行/列的最值即可.
但同行同列中若有相同的? 把这些同行同列相同的数用放到同一个集合,并查集维护要取的值即可.
#include 
using namespace std;
typ]]></description><category></category></item><item><title><![CDATA[Codeforces 665E  Beautiful Subarrays （01Trie)]]></title><link>https://blog.csdn.net/Jeremy1149/article/details/76573775</link><guid>https://blog.csdn.net/Jeremy1149/article/details/76573775</guid><author>Jeremy1149</author><pubDate>Wed, 02 Aug 2017 11:40:14 +0800</pubDate><description><![CDATA[题意:n个元素a[i],问有多少个区间[l,r] 满足a[l]^a[l+1]..a[r] >=k.
n
枚举区间结尾r,如何快速找到有多少个前缀si满足si^sj>=k?
num[u]:记录有多少个前缀经过该结点,查询时保存当前异或和val,
若val+(1=k
若val+(1=k 相反结点子树中任意个前缀都满足,累加其num[u]后,跳到相同结点上继续查询.O(nlogX)
#inc]]></description><category></category></item><item><title><![CDATA[Codeforces 834D The Bakery DP(线段树维护)]]></title><link>https://blog.csdn.net/Jeremy1149/article/details/76423511</link><guid>https://blog.csdn.net/Jeremy1149/article/details/76423511</guid><author>Jeremy1149</author><pubDate>Mon, 31 Jul 2017 12:26:01 +0800</pubDate><description><![CDATA[题意:k个盒子,n个蛋糕,第i个蛋糕为种类a[i],每次把连续一段的蛋糕装到某个盒子中.价值为该盒子里蛋糕种类不同的个数 n
设dp[i][j]:前j个蛋糕放到i个盒子中的最大价值,f(x,j)为[x,j]中蛋糕不同的个数.
dp[i][j]=max(dp[i-1][x-1]+f(x,j)) 用线段树维护dp[i-1][x-1]+f(x,j) 先把dp[i-1][1-n]插入到线段树中,随着j]]></description><category></category></item><item><title><![CDATA[ARC 064F Rotated Palindromes DP(回文移位,循环节)]]></title><link>https://blog.csdn.net/Jeremy1149/article/details/76400260</link><guid>https://blog.csdn.net/Jeremy1149/article/details/76400260</guid><author>Jeremy1149</author><pubDate>Sun, 30 Jul 2017 17:38:55 +0800</pubDate><description><![CDATA[题意:给出n,k.问有多少个长度为n的序列a满足:1
i.e:1,1,2,2 左移一次-> 1,2,2,1. n,k

不考虑移位总共有k^(n/2)个回文,每个都可以操作n次,得到n个合法序列.如何去掉重复的?
回文串的循环节肯定为回文.按照回文串的最小循环节长度来更新答案
若回文串的最小循环节长度为c,经过c次操作后,得到c个序列
当c为偶数时,重复数为一半,奇数时,无重复]]></description><category></category></item><item><title><![CDATA[HDU 6053 TrickGCD DP(筛法)]]></title><link>https://blog.csdn.net/Jeremy1149/article/details/76221990</link><guid>https://blog.csdn.net/Jeremy1149/article/details/76221990</guid><author>Jeremy1149</author><pubDate>Thu, 27 Jul 2017 21:22:50 +0800</pubDate><description><![CDATA[题意:给出序列a,a[i]
1=2

设dp[x]:gcd为x的个数 则b中每个元素都为x的倍数 
b[i]
若a[i]/d=k贡献为k,则和它相同贡献有cnt[kd,(k+1)d-1]个,则总共贡献k^cnt.
最后容斥减掉gcd为jx的部分(j>1).O(nlog^2n)
#include 
using namespace std;
typedef long long ll;
c]]></description><category></category></item><item><title><![CDATA[HDU 4906 Our happy ending 状压DP]]></title><link>https://blog.csdn.net/Jeremy1149/article/details/76160296</link><guid>https://blog.csdn.net/Jeremy1149/article/details/76160296</guid><author>Jeremy1149</author><pubDate>Wed, 26 Jul 2017 18:34:02 +0800</pubDate><description><![CDATA[题意:给出n,k,L,问有多少种长度为n的序列,其0
n,k

某些和最多就20种,状态压一压,第i位二进制为1代表序列和可以为i,
设dp[i][s] 长度为i状态为s的方案数.
每次加入x(x
大于k的数有cnt个 则长度+1,s->s转移到自己就有cnt种方案
#include 
using namespace std;
typedef long long ll;
const ]]></description><category></category></item><item><title><![CDATA[HDU 4901 The Romantic Hero DP(计数)]]></title><link>https://blog.csdn.net/Jeremy1149/article/details/76146047</link><guid>https://blog.csdn.net/Jeremy1149/article/details/76146047</guid><author>Jeremy1149</author><pubDate>Wed, 26 Jul 2017 14:18:51 +0800</pubDate><description><![CDATA[题意:n个数a[i],两个集合s,t,s中下标最大的小于t中下标最小的(s的元素都在t元素的左边),问s中元素的异或和等于t中元素的and和的方法数,n,a[i]

a[i]
这样计算明显有重复,因为1-p  q-n 这两个方案可以在 前缀i,i+1中对应的方案出现(q>>i p
d[i][x] 集合s最后一个数为i时异或和为x的方法数,同时处理出前缀i异或和为y的个数来转移状态.
则集]]></description><category></category></item></channel></rss>