- 博客(22)
- 资源 (1)
- 收藏
- 关注
原创 冲刺NOIp2016算法模板
冲刺NOIp算法模板数据结构栈int strack[maxn];int head;bool b[maxn];void push(int x){ strack[++head]=x; b[x]=true;};int pop(){ int ret; ret=strack[head--]; b[ret]=false;
2017-11-09 23:55:51
1684
原创 treap
比较快的非线性筛法for(int a=2;a<=n;a++) for(int b=a+a;b<=n;b++) not_prime[b]=true;O(nlogn)for(int a=2;a<=n;a++) if(!not_prime[a]) for(int b=a+a;b<=n;b++) not_prime[b]=true; //true不是质数O(nloglogn)
2017-10-30 11:07:41
311
原创 数据结构板子
树堆二叉堆堆排序RMQ(区间最值)#include<iostream>#include<cstdio>#define MAXN 100005using namespace std;int n,m;long long a[MAXN],d[MAXN][18];inline int read (){ int n=0; char ch=getchar(); while(
2017-10-21 19:59:27
325
转载 数论板子
//筛法求MAXN范围以内的素数表,其中需要借用一个bool数组vis void prime_table() { int i,j; for(i = 2;i <= MAXN;i++) { if(!vis[i]) { prime[++cnt] = i; //cn
2017-10-21 19:09:35
610
原创 树状数组
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int n,m;int sum[500005];inline int lowbit (int x){ return x&-x;}int add (int k,int a){ whil
2017-10-21 16:21:10
178
原创 RMQ
#include<iostream>#include<cstdio>#define MAXN 100005using namespace std;int n,m;long long a[MAXN],d[MAXN][18];inline int read (){ int n=0; char ch=getchar(); while(ch<'0'||ch>'9') c
2017-10-20 18:58:14
163
原创 SPFA
自认为优美的SPFA#include<iostream>#include<cstdio>#define maxm 500005#define maxn 10005#define INF 0x5fffffffusing namespace std;int n,m,s;struct Edge{ int next; int to; int w;}e[maxm] ;
2017-10-05 01:22:00
172
原创 还是小套路。。
啦啦啦第一波 网站安利 线段树notonlysuccess codeforces tarjian KMP1 KMP2 KMP3 TRIE1 TRIE2 String Manacher AC自动机1 AC自动机2
2017-07-21 19:36:07
233
原创 二分算法
介绍 在一个单调(递增或递减)的区间[a1,an]中查找元素x,每次将区间分为左右长 度相等的两部分,判断解在哪个区间中并调整区间上下界,重复直至找到x。 复杂度O(lg n) 作用:查找元素是否存在(找出位置或值)求满足条件的最值。 算法原理 1 2 3 4 5 6 7 8 9 10 11 7 10 21 25
2017-07-18 19:44:30
230
原创 并查集
算法思路用于海量集合的合并及查询。 精髓在于路径压缩。 具体瞅代码##代码#include<iostream>#include<cstdio>using namespace std;#define MAXN 200001int f[MAXN];int m,n,x,y,q;int find1(int x)//非递归,不会爆栈,但很可能超时{ while(f[x]!=x)
2017-07-18 19:08:29
214
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人