- 博客(3)
- 收藏
- 关注
原创 树的重心(代码实现)
1.树最多有两个重心 2.如果树有两个重心那么它们两两相邻 #include<iostream> #include<algorithm> #include<cstring> #include<vector> using namespace std; const int N = 200010; vector<int> h[N]; int n; int res = N; int dfs(int u,int fa) { int sum = 1;
2022-05-19 15:31:29 201
原创 合适数对(树状数组+离散化)
题目链接 求区间和用到前缀和,将区间和分类,分成n类,每类都以i结尾,所以我们只要求在i之前的区间和大于等于s[i]-m的数量,所以可以用树状数组维护,因为数值范围很大,所以再加一步离散化 #include<iostream> #include<algorithm> #include<string> #include<cstring> #include<vector> const int N = 400010; using namespace st
2022-04-25 13:38:50 123
原创 Codeforces Round #753 (Div. 3)
A出三道一把掉分局,痛定思痛,写篇总结 A. Linear Keyboard 应用数组或者哈希表简单模拟即可 #include<iostream> #include<algorithm> #include<cstring> #include<vector> #include<cmath> #include<string> #include<queue> #include<unordered_map> using
2021-11-03 19:30:51 148
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人