2022年7月30日
摘要: https://www.luogu.com.cn/problem/P1144 邻接矩阵存图 从1出发bfs 同时记录深度 如果下一个点的深度是起点深度+1,那么此刻应该累加路径的条数。 #include <bits/stdc++.h> using namespace std; #define ll 阅读全文
posted @ 2022-07-30 23:42 樵风 阅读(61) 评论(0) 推荐(0)
摘要: https://www.luogu.com.cn/problem/P2121 毫无特色 #include <bits/stdc++.h> using namespace std; #define MAX 10000001 struct node { long long u, v, w; } edge 阅读全文
posted @ 2022-07-30 23:37 樵风 阅读(30) 评论(0) 推荐(0)
摘要: P5019 应用树状数组维护差分数组 遍历数组,找到一个非0的,在从这里往后找到0的,这中间就是区间修改的区间 区间修改的值为这个区间的最小值,在第二步的时候可以顺便记录下来 #include <bits/stdc++.h> using namespace std; #define ll long 阅读全文
posted @ 2022-07-30 23:28 樵风 阅读(26) 评论(0) 推荐(0)
摘要: P1195 将最小生成树的cnt==n-1改为cnt==n-k即可 还是板子题 #include <bits/stdc++.h> using namespace std; #define MAX 100000000 int n, m, k; struct node { int a, b, c; } 阅读全文
posted @ 2022-07-30 23:22 樵风 阅读(50) 评论(0) 推荐(0)
摘要: P3367 并查集模板。。 #include <bits/stdc++.h> using namespace std; int n, m; #define MAX 1000001 int parent[MAX]; int find(int x) { return (x == parent[x]) ? 阅读全文
posted @ 2022-07-30 23:19 樵风 阅读(25) 评论(0) 推荐(0)
摘要: P2957 数据小直接暴力 遍历字串长度(从大到小),如果满足条件直接输出长度 substr函数使用 #include <bits/stdc++.h> using namespace std; #define MAX 100001 string a, b; int main() { cin >> a 阅读全文
posted @ 2022-07-30 23:16 樵风 阅读(46) 评论(0) 推荐(0)
摘要: P1546 无脑最小生成树 矩阵输入 #include <bits/stdc++.h> using namespace std; #define ll long long #define MAX 10000001 int n, k; int parent[MAX]; int idx; struct 阅读全文
posted @ 2022-07-30 23:16 樵风 阅读(35) 评论(0) 推荐(0)
摘要: P3817 模拟,贪心 遍历数组,如果超过了最大糖果数,便修改数组中对应的值并累加 #include <bits/stdc++.h> using namespace std; #define MAX 1000001 long long n, x; long long datas[MAX]; void 阅读全文
posted @ 2022-07-30 23:11 樵风 阅读(27) 评论(0) 推荐(0)