上一页 1 2 3 4 5 6 7 ··· 19 下一页
摘要: 注意: 这道题不能像小国王那样,预处理出一个useful数组,存储所有可用的状态: for(int i = 2; i <= m + 1; i++) for(int j = 0; j < 1<<n; j++) { f[i&1][j] = 0; for(int k:Trans[j]) f[i][j] + 阅读全文
posted @ 2024-04-01 21:32 Gold_stein 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 线性状压DP #include <iostream> #include <stdio.h> #include <algorithm> #include <string> #include <cmath> #include <vector> #define R(x) x = read() #defin 阅读全文
posted @ 2024-04-01 19:11 Gold_stein 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 这道题的双指针筛选区间方式,和蓝桥杯的那个最大公约数一模一样: #include <iostream> #include <stdio.h> #include <algorithm> #include <string> #include <cstring> #include <string.h> # 阅读全文
posted @ 2024-03-31 20:21 Gold_stein 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 双指针做法: 反过来,从后往前看也是一样的: #include <iostream> #include <stdio.h> #include <algorithm> #include <string> #include <cmath> #define For(i, j, n) for (int i 阅读全文
posted @ 2024-03-31 19:15 Gold_stein 阅读(3) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <stdio.h> #include <algorithm> #include <string> #include <cmath> #define For(i, j, n) for(int i = j ; i <= n ; ++i) usin 阅读全文
posted @ 2024-03-28 09:33 Gold_stein 阅读(8) 评论(0) 推荐(0) 编辑
摘要: 带权并查集中,dist[]数组可以理解为一个向量,这样子比按照距离来理解更透彻: 优秀学习资料: AcWing 240. 食物链(带权并查集) - AcWing 即d[a]表示向量a->fa[a] 这道题的并查集解法: #include <iostream> #include <stdio.h> # 阅读全文
posted @ 2024-03-25 20:36 Gold_stein 阅读(3) 评论(0) 推荐(0) 编辑
摘要: #include <bits/stdc++.h> #define int long long using namespace std; const int N = 3e6 + 9; int a[N]; char b[N]; signed main() { ios::sync_with_stdio(0 阅读全文
posted @ 2024-03-25 14:22 Gold_stein 阅读(16) 评论(0) 推荐(0) 编辑
摘要: 最开始的思路想错了: 把所有是负数段的连成一块,发现下一步会走到这些负数区域的时候,就算出来需要差了多少,然后在当前这个正数块停留一段时间。 但有可能我们当前踩着的这一块正数非常小,导致我们要等很长时间,所以正确的贪心应该是: 记录最大值的位置,先不停往后走,当发现结果变为负数的时候,就算出需要在之 阅读全文
posted @ 2024-03-23 00:25 Gold_stein 阅读(4) 评论(0) 推荐(0) 编辑
摘要: MC里面无限水的模型 #include <iostream> #include <stdio.h> #include <algorithm> #include <string> #include <cmath> #define For(i, j, n) for(int i = j ; i <= n 阅读全文
posted @ 2024-03-23 00:19 Gold_stein 阅读(8) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <stdio.h> #include <algorithm> #include <string> #include <cmath> #define For(i, j, n) for(int i = j ; i <= n ; ++i) usin 阅读全文
posted @ 2024-03-22 16:59 Gold_stein 阅读(11) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 19 下一页