
buct寒假集训
算法训练营相关题目
_zpf
这个作者很懒,什么都没留下…
展开
-
buct寒假集训——可持久化数据结构
文章目录超级马里奥超级马里奥hdu4417正解是用可持久化线段树,时间复杂度 nlogn但是这题的数据好像比较弱,用莫队 nsqrt(n)logn也能过。莫队:#include <bits/stdc++.h>#include<ext/pb_ds/tree_policy.hpp>#include<ext/pb_ds/assoc_container.hpp>using namespace std;using namespace __gnu_pbds;ty原创 2022-02-10 12:00:45 · 449 阅读 · 0 评论 -
buct寒假集训——线段树
文章目录敌兵布阵简单的整数问题数据结构难题敌兵布阵HDU1166树状数组即可#include<bits/stdc++.h>using namespace std;typedef long long ll;#define endl '\n'#define lowbit(x) (x&-x)const int mod=998244353;const int N=50010;int a[100100];int c[100100];int n;//a为原数组,c为树状数原创 2022-02-08 13:10:12 · 856 阅读 · 0 评论 -
buct寒假集训——树状数组
文章目录数星星公路交叉数数星星poj2352#include <bits/stdc++.h>#include<ext/pb_ds/tree_policy.hpp>#include<ext/pb_ds/assoc_container.hpp>using namespace std;using namespace __gnu_pbds;tree<pair<int,int> ,null_type,less<pair<int,int&原创 2022-01-27 11:57:05 · 1023 阅读 · 0 评论 -
buct寒假集训——lca
文章目录最近公共祖先树上距离以下代码使用的是倍增算法求lca最近公共祖先poj1330#include<bits/stdc++.h>using namespace std;const int N=10010;const int M=20010;int h[N], ne[M], to[M];int cnt, root;int fa[N][17];void add(int a, int b){ to[cnt] = b,ne[cnt] = h[a],h[a] = cnt原创 2022-01-24 13:03:02 · 396 阅读 · 0 评论 -
buct寒假集训——RMQ
#include<bits/stdc++.h>using namespace std;typedef long long ll;const int N= 200100;int st_min[N][20];int st_max[N][20];int bin[20],Log[N];int a[N];void init(){ bin[0]=1; for( int i=1;i<20;i++) bin[i]=bin[i-1]*2;//计算2的i次方 Log[原创 2022-01-19 18:43:41 · 327 阅读 · 0 评论 -
buct寒假集训——优先队列
文章目录第k大的数围栏修复由于优先队列和平衡树在时间复杂度上没有显著的差距,代码中全都用set代替的优先队列。第k大的数hdu4006#include <bits/stdc++.h>using namespace std;const int N=20010;int a[N];int main(){ int n; cin>>n; multiset<int>se; for( int i=0;i<n;i++){原创 2022-01-18 14:24:03 · 440 阅读 · 0 评论 -
buct寒假集训——并查集
文章目录通畅工程方块栈食物链帮派通畅工程hdu1232如果两个点集连通在一起,就合并在同一个集合,最终查看集合的总数。#include<bits/stdc++.h>using namespace std;typedef long long ll ;const int N=1010;int fa[N];int find(int x){ if(x!=fa[x]) fa[x]=find(fa[x]); return fa[x]; }void merge( int原创 2022-01-18 14:19:16 · 234 阅读 · 0 评论