上一页 1 2 3 4 5 6 7 8 9 10 ··· 15 下一页
摘要: 【题解】 最短路。那么直接写dijkstra就好了。 1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 #define LL long long 5 #define rg register 6 #define N 20001 阅读全文
posted @ 2018-07-31 18:47 Driver_Lao 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 【题解】 线段树基础题。对于每个修改操作把相应区间的sum改为区间长度-sum即可。 1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 #define LL long long 5 #define rg register 6 阅读全文
posted @ 2018-07-31 18:44 Driver_Lao 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 【题解】 就是个树链剖分的模板题。 1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 #define LL long long 5 #define rg register 6 #define N 200010 7 #defi 阅读全文
posted @ 2018-07-31 18:42 Driver_Lao 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 【题解】 线段树或者单调队列都可以。 1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 #define LL long long 5 #define rg register 6 #define N 1000010 7 #de 阅读全文
posted @ 2018-07-31 18:40 Driver_Lao 阅读(223) 评论(0) 推荐(0) 编辑
摘要: 【题解】 最大值最小化,那么一般要联想到二分。二分一个最大值,然后check一下能否分成小于等于m段即可。 1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 #define LL long long 5 #define rg 阅读全文
posted @ 2018-07-31 18:39 Driver_Lao 阅读(240) 评论(0) 推荐(0) 编辑
摘要: 【题意概述】 给出一个长度为n的序列a,求有多少对[i,j]满足i<j且a[i]>max(a[i+1],a[i+2],...,a[j]). 【题解】 单调栈。 倒着处理序列的元素,维护一个单调递减的栈,同时记录栈中的每个元素进栈的时间。如果当前元素x大于栈顶元素,那么栈顶到第二个元素在原素列之间的这 阅读全文
posted @ 2018-07-31 17:55 Driver_Lao 阅读(264) 评论(0) 推荐(0) 编辑
摘要: 【题解】 维护一个单调栈即可。 但是因为有相同身高的存在,所以要稍微考虑下相同身高的处理。因为这个卡了一下下QAQ... 1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 #define LL long long 5 #de 阅读全文
posted @ 2018-07-30 17:39 Driver_Lao 阅读(157) 评论(0) 推荐(0) 编辑
摘要: 【题解】 每个软件只依赖另一个软件,且依赖关系不构成环,那么很容易想到这是树形结构。 我们用1表示以安装,用0表示未安装或已卸载;那么安装一个软件,就是把它到树根的路径上所有的点都改为1;卸载一个软件,就是把它的子树全部改为0. 状态改变的软件包数就是操作前后整棵树的点权和。 这样我们直接树链剖分即 阅读全文
posted @ 2018-07-28 10:32 Driver_Lao 阅读(216) 评论(0) 推荐(0) 编辑
摘要: 【题解】 其实解法 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #define LL long long 5 #define rg register 6 #define N 200010 7 using namespa 阅读全文
posted @ 2018-07-21 22:50 Driver_Lao 阅读(234) 评论(0) 推荐(0) 编辑
摘要: 【题解】 用最短路算法求A到B被扣除的最小百分比即可。稍微修改一下最短路的更新方式即可。 1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 #include<cmath> 5 #define LL long long 6 # 阅读全文
posted @ 2018-07-21 21:59 Driver_Lao 阅读(233) 评论(0) 推荐(0) 编辑
摘要: 【题解】 线段树维护区间中1的个数就好了。每次修改就打上标记并把区间的sum改为len-sum. 1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 #define LL long long 5 #define N 20001 阅读全文
posted @ 2018-07-20 22:40 Driver_Lao 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 【题解】 其实就是求逆序对。直接上树状数组就好了。 1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 #define LL long long 5 #define rg register 6 #define N 500010 阅读全文
posted @ 2018-07-13 20:53 Driver_Lao 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 【题解】 题意就是判断树上两条链是否有交。口诀是“判有交,此链有彼祖”。即其中一条链的端点的Lca在另一条链上。 我们设两条链的端点的Lca中深度较大的为L2,对L2与另一条链的两个端点分别求Lca,若满足其中一个Lca等于L2,即表示两链有交。 1 #include<cstdio> 2 #incl 阅读全文
posted @ 2018-07-12 18:48 Driver_Lao 阅读(612) 评论(0) 推荐(0) 编辑
摘要: 【题解】 直接二分答案即可。 1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 #define LL long long 5 #define rg register 6 #define N 200010 7 using na 阅读全文
posted @ 2018-07-11 21:36 Driver_Lao 阅读(225) 评论(0) 推荐(0) 编辑
摘要: 【题解】 二分答案。 check的方法:把给出的坐标排序,从小到大扫一遍,如果当前坐标与上一个放牛的位置相差超过mid,就把cnt加一,最后判断cnt是否符合要求即可。 1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 #d 阅读全文
posted @ 2018-07-11 18:49 Driver_Lao 阅读(266) 评论(0) 推荐(0) 编辑
摘要: 【题解】 二分答案即可。 注意树的总高度会超过int,所以尽管M不超过int,check的时候还是要开Long Long,避免不必要的麻烦。 1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 #include<cstdlib 阅读全文
posted @ 2018-07-11 18:34 Driver_Lao 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 【题解】 二分答案。 给出的是两位小数,并没有什么影响,乘100转化成整数就很方便了。 1 #include<cstdio> 2 #include<algorithm> 3 #define LL long long 4 #define rg register 5 #define N 200010 6 阅读全文
posted @ 2018-07-11 18:31 Driver_Lao 阅读(283) 评论(0) 推荐(0) 编辑
摘要: 【题解】 开26棵线段数,记录区间内每种字母的出现次数,修改的时候就用区间设置为一个数操作即可。同时也有平衡树做 1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 #define LL long long 5 #define 阅读全文
posted @ 2018-05-25 18:38 Driver_Lao 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 【题解】 DP题,用f[i][j]表示以i为最后一个数、以j为倒数第二个数的等差数列的长度。转移显然,不过在寻找满足a[i]-a[j]=a[j]-a[k]的k的时候,要注意随着i的递增,k其实是递减的,所以总的复杂度可以降到n^2. 1 #include<cstdio> 2 #include<alg 阅读全文
posted @ 2018-05-24 13:58 Driver_Lao 阅读(287) 评论(0) 推荐(0) 编辑
摘要: 【题解】 二分一个最大值,check一下分出来的组数是否小于等于k即可。 1 #include<cstdio> 2 #include<algorithm> 3 #define LL long long 4 #define rg register 5 #define N 200010 6 int n, 阅读全文
posted @ 2018-05-24 12:38 Driver_Lao 阅读(298) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 10 ··· 15 下一页