2022年7月31日
摘要:
https://www.luogu.com.cn/problem/P6686 记录每个长度的棍子的个数 枚举每个长度,作为腰长 再遍历到腰长两倍以内的,这些累加进去得到满足条件的底的个数 第三步不需要从头遍历,累计的次数k也不需要归0,因为小的腰长对应的底边的个数一定在大的腰长对应底边个数以内,就不
阅读全文
posted @ 2022-07-31 01:31
樵风
阅读(27)
推荐(0)
摘要:
P3378 堆好麻烦直接偷懒用优先队列吧 优先小队列(堆顶为最小元)创建priority_queue<int, vector<int>, greater<int>> q; #include <bits/stdc++.h> using namespace std; priority_queue<int
阅读全文
posted @ 2022-07-31 01:23
樵风
阅读(18)
推荐(0)
摘要:
https://www.luogu.com.cn/problem/P1106 将字符串中出现递减的数删去(s[i]>s[i+1])此时删去i位置的那个比较大的数 使用erase函数快 循环操作n次结束 #include <bits/stdc++.h> using namespace std; str
阅读全文
posted @ 2022-07-31 01:19
樵风
阅读(40)
推荐(0)
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
樵风
阅读(60)
推荐(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
樵风
阅读(29)
推荐(0)
摘要:
P5019 应用树状数组维护差分数组 遍历数组,找到一个非0的,在从这里往后找到0的,这中间就是区间修改的区间 区间修改的值为这个区间的最小值,在第二步的时候可以顺便记录下来 #include <bits/stdc++.h> using namespace std; #define ll long
阅读全文
posted @ 2022-07-30 23:28
樵风
阅读(24)
推荐(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
樵风
阅读(49)
推荐(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)
摘要:
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
樵风
阅读(34)
推荐(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
樵风
阅读(45)
推荐(0)