09 2020 档案
摘要:https://www.luogu.com.cn/problem/P6008 十分玄学 刚开始打算建森林树形dp,结果不会建立树,看了题解发现合并集合时候乘起来就好,没必要非得建树,想法和树形dp一样 dp1表示画水,dp0表示不用水,由于高的点画了水,连通块的点都会有水,所以高处放水只有一种方案。
阅读全文
摘要:P6075 [JSOI2015]子集选取 luogu.com.cn/problem/P6075 https://www.cnblogs.com/wxq1229/p/12295145.html具体可以参考这里 说一下总结,计数时候要看看是不是有什么东西相互独立的,可以利用乘法原理。 一个人走n步时候(
阅读全文
摘要:https://www.luogu.com.cn/problem/P4068 质因数分解然后建立二分图,跑费用流 具体看第一个官方题解的代码就好了,我想说的是费用流控制流量使得费用大于0且流量最大的方法,具体看代码,受益匪浅 #include<iostream> #include<vector> #
阅读全文
摘要:https://ac.nowcoder.com/acm/contest/7413/B 神奇的题,公式可以看代码 已知n和m,ans = C(n,0)+C(n,1) .....C(n,m+1); 这个要分开看。 C(n,0)+C(n,1)+C(n,2)的含义为 长度为0,1,2的集合有这么多种排列方法
阅读全文
摘要:https://codeforces.com/contest/1393/problem/D 矩阵dp,数有几个菱形,一般好像就是以某个位置为底,然后去dp 具体看代码吧,没啥可说的 ,都是玄学dp #include<iostream> #include<cstring> using namespac
阅读全文
摘要:https://codeforces.com/contest/1400/problem/E 可以横着把有连续的数字-1,或者把某一个数字清0,问你最少操作几次,分治 555 555 555操作3次,1 1 1操作1次 具体看代码把 #include<iostream> #include<cstrin
阅读全文
摘要:https://www.luogu.com.cn/problem/P3761 这是个神仙题,会卡常 题目让你改一条边把直径变得最短。 枚举每条边,会把图分成两个地方,两个连通块(x区和y区域)都换根dp一下,算出离x最远的点的距离记为dis【x】。然后枚举一下 新直径有三个来源 1 max dis[
阅读全文
摘要:https://codeforces.com/contest/1407/problem/E 玄学题,有一个重要的事情,反向建边,边指向的点颜色一致,那就从n开始bfs,第一次遇到必定要和边反色,因为不反色的话路就短了。。。(第一次遇到的路一定是最短的) 具体看代码,写法简单,参考LDK神仙 #inc
阅读全文
摘要:https://codeforces.com/contest/1407/problem/D 这神仙题啊,举个例子 4 5 6 5 6 3 这样的序列如何建边? //先只考虑中间部分比i j大的 4 4 5 4 5 4 5 6 5 6 4 5 5 5 5 4 5 4 5 6 5 6 3 4 5 6 3
阅读全文
摘要:https://ac.nowcoder.com/acm/contest/5671/H 这个题前导0是无所谓的 dp[pos][a][b][up][up2],pos 100(位置),a,b1000(a数字和b数字的和),up,up2(a是否达到N的上界,b是否达到a的上界) 3,会超时,需要优化 试想
阅读全文
摘要:https://codeforces.com/contest/1405/problem/D 我是zz,看错题了,其实就两种可能 1.开局直接被抓住 disA >= dis(a,b) 2.逃跑,但是如何跑呢?我们发现,db >= 2*da + 1就能跑的了,因为db小的化迟早会被抓住,放风筝就好了,看
阅读全文
摘要:https://www.luogu.com.cn/problem/P3413 回文长度2或者3就可以裁定,值得注意的是dp[pos][pre][ppre]可能应对3334321和5554321(都有321),所以要引入最新的变量才行。 dp[pos][pre][ppre][sum],具体套了板子,返
阅读全文
摘要:https://www.luogu.com.cn/problem/P2602 挺简单 的其实,板子题 真实的模板 #include<bits/stdc++.h> using namespace std; typedef long long ll; int len,a[2000]; ll l,r,dp
阅读全文
摘要:https://leetcode-cn.com/problems/count-all-possible-routes/ dp[x][y]从x到终点,使用y的油。 具体看注释 #include<iostream> #include<algorithm> #include<cstring> #inclu
阅读全文
摘要:https://ac.nowcoder.com/acm/contest/5671/J 牛客多校j题,利用线段树nlogn写出模拟的操作快速幂 可以类似给转圈用 #include<iostream> #include<set> using namespace std; typedef long lon
阅读全文
摘要:https://ac.nowcoder.com/acm/contest/7225/A 一句话,按照list转一圈,把list按照list转之后就是转两圈,快速幂的思想 #include<iostream> #include<algorithm> #include<cstring> #include<
阅读全文
摘要:博弈论 https://codeforces.com/contest/1397/problem/D 如果随便取走,只要是奇数就是先手赢,现在他规定不能重复取前人取过的,那就意味着8 2 2 2 ,先手占领8,就必胜了,如果4 4 4 4 4 这样均势,a先手每次找最大的取,只要是奇数就能赢 想不到啊
阅读全文
摘要:https://ac.nowcoder.com/acm/contest/7079/C 由题可知是最小生成树,先把比L【i】小的连通块建立好,合并集合x,y可得 》 par[y] = x,ans += siz[x]*siz[y],siz[x] += siz[y]; #include<iostream>
阅读全文
摘要:https://codeforces.com/contest/1400/problem/D i<j<k<l 假设x = list【j】 y = list【k】 可以枚举j和k,0 j-1有a个y,k+1 -- n有b个x,ans+=a*b枚举就好了 具体看代码 #include<iostream>
阅读全文
摘要:https://codeforces.com/contest/1400/problem/B 有一点很重要,s能用完就一定会用完,枚举我用几个s就好 #include<iostream> #include<cstring> #include<queue> #include<algorithm> usi
阅读全文

浙公网安备 33010602011771号