自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(11)
  • 收藏
  • 关注

原创 边数受限的最短路(状态压缩DP)

#include #include #include using namespace std; const int maxn=1<<10; const int maxm=31; const int INF=1<<29; int t[maxm]; int d[maxm][maxm]; double dp[maxn][maxm]; void solve() { for(int i=0;i<(1<<n);i++) fill(da[i],dp[i]+m+1,INF); dp

2021-01-10 14:53:05 72

原创 剪苹果枝(树上DP)

#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; const int ee=105; int n,q; int tree[ee][5]={0},ma[ee][ee]={0},num[ee]={0},f[ee][ee]={0}; void preprocess() { for(int i=0;i<=

2021-01-10 12:29:14 80

原创 AC自动机

#include #include #include using namespace std; const int maxnode=11000; const int sigma_size=26; struct AC_Automata { int ch[maxnode][sigma_size]; int val[maxnode]; int f[maxnode]; int l[maxnode]; int sz; void init(){ sz=1; memset(ch[0],0,sizeof(ch[0]));

2021-01-08 21:32:59 56

原创 KMP

#include #include #include #include using namespace std; #define MAXN 1010 int ans; char text[MAXN],pattern[MAXN]; int next[MAXN]; void getNext(){ int m=strlen(pattern); next[0]=next[1]=0; for(int i=1;i<m;i++){ int j=next[i]; while(j&&pattern[j]

2021-01-08 16:50:25 46

原创 求最大异或数(Tire树)

#include #include #include #difine maxn 10000+5 using namespace std; typedef long long LL; ina a[maxn],n,m; int ch[32maxn][2]; LL val[32maxn]; int code_cnt; void inti(){ node_cnt=1; memset(ch[0],0,sizeof(ch[0])); } void Insert(LL x){ int u=0; for(int i=

2021-01-08 15:56:06 113

原创 Tire树

const int maxnode=4000100+10; const int sigma_size=26; stuct Tire{ int ch[maxnode][sigma_size]; int val[maxnode]; int sz; } void clear(){sz=1;mamset(ch[0],0,sizeof(ch[0]));} int idx(char c){return c-‘a’;} void insert(const chars,int v){ int u=0,n=strlen(s)

2021-01-08 13:14:51 51

原创 求波动值(SPLAY树实现)

#include #include using namespace std; const int inf=0x7fffffff; struct splay_tree{ unsigned long p_size; struct node{ node l,r,p; int key; node(int key):l(NULL),r(NULL),p(NULL),key(key){} ~node(){ if(l)delete l; if®delete r; if§delete p; } }root; void r

2021-01-05 18:02:33 246

原创 插入输出(TREAP)

#include <stdlib.h> #include struct Node{ int size,key,weight; Node* l,* r; Node(int key):key(key){ size=1; weight=rand(); l=r=NULL; } }; int get_size(Nodenode){ return node==NULL?0:node->size; } void left_rotate(Node&a){ Node* b=a->r;

2021-01-04 21:12:18 52

原创 已知A求单增B使得∑|Ai-Bi|最小(左倾堆实现)

1.左倾堆的节点的键值小于等于子节点的键值(堆性质) 2.左孩子的NPL大于等于右孩子的NPL(左倾性质) 3.NPLF=NPLRC+1 4.左倾堆的子树为左倾堆 #include #include #include #include using namespace std; const int N=50005; int a[N],root[N],num[N]; struct LHeap{ int l,r,key,dis,sz; bool operator<(const LHeap lh)co

2021-01-04 17:48:14 304

原创 逆序数(树状数组实现)

#include #include using namespace std; const int N=1000; int lowbit(int x){ return x&(-x); } void change(int *c,int position,int value,int len) { while(position<=len){ c[position]+=value; position+=lowbit(position); } } int sum(int *c,int n){ int

2021-01-03 12:29:55 51

原创 堆排序

#include /* run this program using the console pauser or add your own getch, system(“pause”) or input loop / void heap_adjust(int a,int f,int n) { int c=2f+1; int t=a[f]; while(c<n){ if(c+1<n&&a[c+1]>a[c])c++; if(a[f]>=a[c])break; a[f]

2021-01-02 12:53:01 47

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除