摘要: #include<bits/stdc++.h> using namespace std; const int N=1e5+20; const int mod=998244353; int a[N]; int n; int k,len; int dp[N][118]; //设dp[i][j]为考虑前i 阅读全文
posted @ 2021-10-05 20:31 Hehe_0 阅读(40) 评论(0) 推荐(0)
摘要: 链接 给一个 $n$ 个点的树,点有标号,求有多少个点对 $i,j$ 满足 $i < j,|i - j| \ge \text{dist}(i,j)$ 其中 $\text{dist}(i,j)$ 表示 $i$ 到 $j$ 的距离。 #include<bits/stdc++.h> using names 阅读全文
posted @ 2021-10-02 18:20 Hehe_0 阅读(62) 评论(0) 推荐(0)
摘要: 单调队列优化. #include<bits/stdc++.h> using namespace std; const int N=7e7+7; int n,m,l,u,v,t; int a[N],p1[N],p2[N]; priority_queue<int > q; double p; //我们要 阅读全文
posted @ 2021-09-25 10:24 Hehe_0 阅读(49) 评论(0) 推荐(0)
摘要: 在同一段时间段里滑动方向是一致的 由于有家具,所以我们每次滑动一格子。(特判的时候要注意边界 dp的 i,j 表示坐标的位置 我们的队列中如果比我们的答案要劣,那么我们就把它弹出来 在单调队列中,我们需要的往往是队头的优答案 dp[x][y] = max ( dp[x][y] , q[l].len 阅读全文
posted @ 2021-09-17 21:30 Hehe_0 阅读(44) 评论(0) 推荐(0)
摘要: 很有意思的题 zty提了一嘴 感觉ZRQ的理解真的很妙 具体看代码注释 #include<bits/stdc++.h> using namespace std; const int N=36; const int mod=2017; int base[N][N],num[N][N]; int n,m 阅读全文
posted @ 2021-09-14 19:18 Hehe_0 阅读(37) 评论(0) 推荐(0)
摘要: by luogu 期望dp WJMZBMR打osu! / Easy 很好的题,但是我太菜了 我开始的思路是统计?的个数,然后dfs处理 但是发现N3e5我的想法也无法实现 len记录当前一连串 o 的个数 当遇到 x 时处理结束; #include<bits/stdc++.h> using name 阅读全文
posted @ 2021-09-13 20:23 Hehe_0 阅读(62) 评论(0) 推荐(0)
摘要: 长链剖分 一个dp dp[i][j]距离i节点的子树中为j的节点数 #include<bits/stdc++.h> using namespace std; const int N=1e6+7; //长链剖分 int head[N],nxt[N<<1],to[N<<1]; int _; void a 阅读全文
posted @ 2021-09-13 17:27 Hehe_0 阅读(43) 评论(1) 推荐(0)
摘要: by luogu //审题:看上去是个背包但是它并不能直接背//题目中我们如果选了一个物品他会造成后效性 // 前i个物品我们使得长度为j的最大价值//dp[i][j] = max(dp[k][j-a[i]]+b[i]+w[k][i]) (根据前人经验,由于可能存在负数(a,b,w)所以我们加个者, 阅读全文
posted @ 2021-09-08 20:08 Hehe_0 阅读(60) 评论(0) 推荐(0)
摘要: by luogu 一开始尝试去dp,发现状态没有办法找完全,于是搂了眼标签 哦,我们可以尝试去化简式子 写道代码里了(没用LATEX 我们考虑一下同一景点中尝试调整一下票价(由于max( (ai - bi * x),0 )代表的是人数,所以就当作) 假如+1,那么变化量: [(x+1)*ai​−(x 阅读全文
posted @ 2021-09-03 20:38 Hehe_0 阅读(51) 评论(0) 推荐(0)
摘要: 不得不说感觉SDOI的题都好值得回味啊 思路题: 我们应该如何规避掉重复路线 我们可以将一个点拆成两个点,一个入一个出,这样的话在十字路口就可以防止重复了 容量为一,权值为零,然后变为最小费用最大流 之后就比较裸的code了 #include<bits/stdc++.h> using namespa 阅读全文
posted @ 2021-08-31 22:20 Hehe_0 阅读(34) 评论(0) 推荐(0)