上一页 1 ··· 5 6 7 8 9 10 11 12 13 下一页
摘要: 平衡树 treap模板 #include<bits/stdc++.h> using namespace std; const int N = 1e5+10,INF = 0x3f3f3f3f; int idx; struct NODE{ int l,r; int key,val; int cnt,si 阅读全文
posted @ 2022-05-25 14:31 xhy666 阅读(28) 评论(0) 推荐(0)
摘要: 求以1为根的生成树各个节点与根距离之和的最小值,各个节点与根的距离最小值可以用dij求出 保留的边的数量一定是n-1条 #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<LL,int> PL 阅读全文
posted @ 2022-05-24 20:43 xhy666 阅读(96) 评论(0) 推荐(0)
摘要: 找出三元组i,j,k(i<j<k,ai,aj,ak互不相等) 等价于找出ai,aj,ak(ai<aj<ak,i,j,k互不相等) #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 2e5+ 阅读全文
posted @ 2022-05-24 18:50 xhy666 阅读(42) 评论(0) 推荐(0)
摘要: y总做法:建立一个虚拟原点,到所有物品的距离为物品原本价值,物品之间的距离为交易价值,枚举等级范围跑最短路即可 我的做法:以女儿为原点反向建图,物品之间的距离为交易价值,到每个物品的最短路加上这个物品的原本价值即为总花费,取最小 时间复杂度均为O(n^2*logn)(dij堆优化) #include 阅读全文
posted @ 2022-05-22 20:49 xhy666 阅读(50) 评论(0) 推荐(0)
摘要: 每个节点到其余节点的最长距离可以分为向上走和向下走两类: 向下走:dfs_down,求每个子节点向下走的最长距离,用子节点维护父节点 向上走:dfs_up,分为两类,一类是父节点向下走的的最长距离,一类是向上走的,因为父节点向下走的最长距离可能经过此节点,所以对于每个节点需要维护向下走的最大值和次大 阅读全文
posted @ 2022-05-22 00:55 xhy666 阅读(39) 评论(0) 推荐(0)
摘要: 树状数组+二分 sum(x)返回x之前有多少个点已经被取走了,a[i]+1为左边界,n为右边界,判断sum(x)和(x-1-a[i])大小即可 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N 阅读全文
posted @ 2022-05-21 16:20 xhy666 阅读(30) 评论(0) 推荐(0)
摘要: 带权并查集,d[x]维护x到父节点的距离 #include<bits/stdc++.h> using namespace std; const int N = 1e5+10; int fa[N],d[N]; int find(int x){ if(x!=fa[x]){ int t=find(fa[x 阅读全文
posted @ 2022-05-17 20:29 xhy666 阅读(30) 评论(0) 推荐(0)
摘要: 对于第i(1<=i<=n)列为最终状态,分为3种情况 f[0][i]表示这列的没有'*' f[1][i]表示这列有且仅有第一行有'*' f[2][i]表示这列有且仅有第二行有'*' #include<bits/stdc++.h> using namespace std; const int N = 阅读全文
posted @ 2022-05-17 16:23 xhy666 阅读(28) 评论(0) 推荐(0)
摘要: 码一下 [算法]Huffman树(哈夫曼树) 阅读全文
posted @ 2022-05-12 19:14 xhy666 阅读(27) 评论(0) 推荐(0)
摘要: #include<bits/stdc++.h> using namespace std; const int N = 110; const double eps = 1e-8; int n; double a[N][N]; int gauss(){ int r,c; for(r=0,c=0;c<n; 阅读全文
posted @ 2022-05-12 15:19 xhy666 阅读(31) 评论(0) 推荐(0)
上一页 1 ··· 5 6 7 8 9 10 11 12 13 下一页