自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 splay 学习笔记

splay 核心函数splay:每次访问一个节点,都把该节点转到根 (包括插入/查找/操作) 思想:对于访问频率较高的节点,使其处于根节点附近,从而保证log复杂度 splay可以维护中序遍历是有序序列 也可维护 中序遍历是当前操作后的序列 AcWing 2437. Splay P1486 [NOI2004] 郁闷的出纳员 const int N=1e5+10; struct node{ int s[2],fa,v; //son,fa,val int sz,tag; //flag懒标记 }t[N];

2021-03-06 09:40:32 106

原创 可持久化数据结构——学习笔记

可持久化前提: 本身的拓扑结构不改变 (平衡树左右旋,拓扑结构改变,不可持久化) 核心思想: 存下数据结构的所有历史版本时,只记录每个版本与前一个版本 改变的部分,每次新增部分至多log(n)个节点,m次为mlog(n) 可持久化trie: 算法步骤: 1、插入:枚举str的每一位,当前位s[i]新建一个节点,当前位的其余字符都与上一版本相同,直接copy 2、查询:查询(l,r)的某个信息时,利用历史版本的可减性,®-(l-1)得到区间(l,r)的信息 P4735 最大异或和 题意:在前缀和{S[i]}中

2021-03-03 21:53:32 128 1

原创 AC自动机学习笔记

AC自动机 trie+kmp 构建fail指针 朴素思想: 当前节点为p,之前已求得fail[p] trie[p,c]是p 通过字符c指向的 一个子节点,现要求fail[ trie[p,c] ],即fail[x] 若trie[fail[p],c]存在,则fail[x]=trie[fail[p],c], 即p的子节点的fail = p的fail的子节点 否则,让p一直跳fail指针,fail[x]=trie[fail[fail[p]],c],直到存在 / 根节点 fail路径压缩后,可优化为trie图 匹配查

2021-03-03 21:26:05 118 1

原创 平衡树 treap 学习笔记

平衡树 treap 平衡树本质上是维护一个有序序列 (中序遍历) treap将随机性作用于堆性质,并通过左旋 / 右旋维护,将树高维护在O(logn) 基本操作 插入数值x 删除数值x 查询数值x的排名(若有多个相同的数,应输出最小的排名)。 查询排名为x的数值。 求数值x的前驱(前驱定义为小于x的最大的数)。 求数值x的后继(后继定义为大于x的最小的数)。 STL set没有的操作: 1、get_rank_by_key 2、get_key_by_rank 1、删除操作: 先查找需要删除的节点,将其旋转到叶

2021-03-01 23:16:02 93

原创 Codeforces Round #639 (Div. 2) BC

B 找规律 可以想象为 \\ 这样斜向右的摆放, 每加一层,相当于把 最右边的 \ 向右平移复制一次, 再加上最顶部的3个 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int MAX_N=3e4+5; long long f[MAX_N]; int main() { f[1]=2; ll x=5; long long mx=30000; for(int i=2;i<=mx;i

2020-05-14 22:19:06 169

原创 Codeforces Round #641 (Div. 2) BC

B dp 限制最长升的前后元素下标是倍数关系, 只有下标是倍数关系才能转移 也就是说对于每个i,只能转移到 i 的倍数, 即外循环枚举i,内循环枚举倍数 倍数法的时间复杂度为 nlogn #include<bits/stdc++.h> using namespace std; const int MAX_N=1e5+5; int a[MAX_N],f[MAX_N]; //表示以i结尾的最大长度 int main() { int t; cin>>t; while(t--)

2020-05-14 22:00:33 185

原创 Codeforces Round #638 (Div. 2) BC

B 要构造一个循环节为k的字符串 计算相异元素个数c, 若c>k,不可能构造 若c<=k,取c个不同元素,再用相同元素补足k个, 由于不限制插入个数,把每个数都延长为一个循环,即输出n个循环 #include<bits/stdc++.h> using namespace std; const int MAX_N=105; int a[MAX_N],cnt[MAX_N],v[MAX_N]; vector<int> tab; int main() { int t; c

2020-05-14 21:36:48 129

原创 算法优化专题

题目 A - Stars POJ - 2352 Astronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars ...

2020-03-10 21:12:00 234

原创 codeforces 排位赛4

传送门 题面 B. Diverse Garland time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output You have a garland consisting of n lamps. Each lamp is colored red, g...

2020-03-10 19:55:08 233

原创 codeforces 排位赛3

传送门 题面 A. Wormhole Sort time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Farmer John’s cows have grown tired of his daily request that they sort...

2020-03-09 21:28:14 299

原创 codeforces 排位赛2

传送门 题面 A. Fence Planning time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Farmer John’s N cows, conveniently numbered 1…N (2≤N≤105), have a comp...

2020-03-09 20:40:43 172

原创 codeforces 排位赛1

传送门 题面 A. Cow Gymnastics time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output In order to improve their physical fitness, the cows have taken up gym...

2020-03-09 20:10:36 257

原创 2019寒假专题一 L CodeForces - 1260B

题面 B. Obtain Two Zeroes time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output You are given two integers a and b. You may perform any number of opera...

2020-01-28 20:32:17 170

原创 2019寒假专题一 F bfs POJ - 1426

题面 给定一个正整数n,请编写一个程序来寻找n的一个非零的倍数m,这个m应当在十进制表示时每一位上只包含0或者1。你可以假定n不大于200且m不多于100位。 提示:本题采用Special Judge,你无需输出所有符合条件的m,你只需要输出任一符合条件的m即可。 Input 输入包含多组数据,每组数据仅一行,只包含一个正整数n (1 <= n <= 200). Output 对于输入...

2020-01-28 18:50:26 217

原创 2019寒假专题一 dfs求连通块 入门题 B POJ 2386 C POJ 1979

B 题面 题面描述 分析 代码 C 题面 题面描述 分析 代码

2020-01-28 18:38:18 142

原创 2019寒假专题一 A - 尺取模板题 POJ - 3061

题面 A sequence of N positive integers (10 < N < 100 000), each of them less than or equal 10000, and a positive integer S (S < 100 000 000) are given. Write a program to find the minimal lengt...

2020-01-28 18:16:37 112

原创 二分 三分专题

题面 农夫 John 建造了一座很长的畜栏,它包括N (2 <= N <= 100,000)个隔间,这些小隔间依次编号为x1,…,xN (0 <= xi <= 1,000,000,000). 但是,John的C (2 <= C <= N)头牛们并不喜欢这种布局,而且几头牛放在一个隔间里,他们就要发生争斗。为了不让牛互相伤害。John决定自己给牛分配隔间,使任意两...

2020-01-25 18:11:34 205

空空如也

空空如也

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

TA关注的人

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