摘要: 1 /**\ 2 https://ac.nowcoder.com/acm/contest/26077/1004 3 最短路dijstra,既然从a -> b -> c最长,等价求b ->a + b -> c 4 枚举中继点 然后求出最短路的和的最大值即可 5 \**/ 6 #include <bit 阅读全文
posted @ 2022-03-21 18:02 std&ice 阅读(58) 评论(0) 推荐(0) 编辑
摘要: 1 #include <bits/stdc++.h> 2 using namespace std; 3 const int N = 1e3 + 10; 4 int n, d[N]; //n个数 离散化后数组 5 struct node { 6 int x, id; 7 bool operator<( 阅读全文
posted @ 2022-03-20 11:05 std&ice 阅读(63) 评论(0) 推荐(0) 编辑
摘要: 1 /**\ 2 https://codeforces.com/problemset/problem/1593/E 3 拓扑排序 每次去掉k次叶子节点, 问最后能留下多少个顶点 4 (本题以入度为1作为叶子节点) 5 \**/ 6 #include <bits/stdc++.h > 7 using 阅读全文
posted @ 2022-03-15 08:19 std&ice 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 1 /**\ 2 https://codeforces.com/contest/522/problem/D 3 离线查询, 按照右端点小的排前面, 4 使用p[x] 记录a[x]出现相同值的前一个位置, p[x]当作线段树的坐标, x - p[x]为值, 5 olgN进行加点, 然后查询 6 \** 阅读全文
posted @ 2022-03-10 10:32 std&ice 阅读(56) 评论(0) 推荐(0) 编辑
摘要: 1 /**\ 2 https://codeforces.com/problemset/problem/1609/C 3 一堆数相乘是质数,其中只有一个是质数, 4 统计左边的1的个数,右边1的个数,累加即可 5 \**/ 6 #include <bits/stdc++.h> 7 using name 阅读全文
posted @ 2022-03-09 17:54 std&ice 阅读(60) 评论(0) 推荐(0) 编辑
摘要: #include <bits/stdc++.h> using namespace std; const int N = 1009; int n; int a[N], f[N]; signed main() { ios::sync_with_stdio(false); cin >> n; for(in 阅读全文
posted @ 2022-03-09 10:58 std&ice 阅读(46) 评论(0) 推荐(0) 编辑
摘要: 1 /**\ 2 每组物品有若干个,同一组内的物品最多只能选一个 3 \**/ 4 #include <bits/stdc++.h> 5 using namespace std; 6 const int N = 1e3 + 9; 7 int n, m, v[N][N], w[N][N], s[N]; 阅读全文
posted @ 2022-03-09 10:54 std&ice 阅读(48) 评论(0) 推荐(0) 编辑
摘要: /**\ n种物品,第i种物品重量wi,价值vi,物品ci个,背包容量为m 例如某物品a,价值v,重量w,数量c个。 假设c=13,有13这样子的物品,我们使用二进制拆分,将13拆分为几个整数的和 拆成1、2、4、6,这样子1~13中任何的数都能由任意两个数组成。 for (int i = 1; i 阅读全文
posted @ 2022-03-09 10:48 std&ice 阅读(58) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 #define int long long 3 using namespace std; 4 const int mx = 1e7 + 9; 5 int n, m, dp[mx], w[mx], v[mx]; 6 signed main() { 7 c 阅读全文
posted @ 2022-03-09 10:34 std&ice 阅读(50) 评论(0) 推荐(0) 编辑
摘要: 普通版本 /**\ f[i][j] 表示 前i件物品容量为j时最大价值 \**/ #include <bits/stdc++.h> using namespace std; const int N = 1010; int n, m, v[N], w[N], f[N][N]; signed main( 阅读全文
posted @ 2022-03-09 10:29 std&ice 阅读(54) 评论(0) 推荐(0) 编辑