会员
周边
新闻
博问
闪存
众包
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
ouhq
博客园
首页
新随笔
联系
订阅
管理
上一页
1
2
3
4
5
6
下一页
2024年1月
最长公共子序列
摘要: 找出最长公共子序列:最长公共子序列 把问题转换为求最长上升子序列 o(nlogn). for(int i=1;i<=n;i++){ //对于数字 cin>>x; mp[x]=i; } vector<int> vct; for(int i=1;i<=n;i++){ cin>>x; if(vct.siz
阅读全文
posted @ 2024-01-23 18:24 osir
阅读(6)
评论(0)
推荐(0)
2023年12月
Manacher(马拉车)--最长回文子串
摘要: //洛谷https://www.luogu.com.cn/problem/P3805 int d[22000007]; //二倍长度 char s[22000007]; int k=0,len,maxn=INT_MIN; void manacher(char s[]){ //复杂度o(n) d[1]
阅读全文
posted @ 2023-12-13 13:14 osir
阅读(13)
评论(0)
推荐(0)
不同树状数组的实现
摘要: 单点修改--单点查询 #include <bits/stdc++.h> using namespace std; //区间查询,单点修改 int n,m; int arr[500005]; int c[500005]; #define lowbit(x) ( (x)& -(x) ) void upd
阅读全文
posted @ 2023-12-01 13:04 osir
阅读(10)
评论(0)
推荐(0)
2023年11月
Lis--Lnds--Lds--Lnis & Dliworth
摘要: 用vector模拟队列:贪心+二分--最后vct.size()则为最长子序列的长度 1.Lis(最长上升子序列): 遍历每一个数字x,若x>vct中最后一个数字,直接加入;否则lower_bound找到第一个>=x的数字,并替换为x; 2.Lnds(最长非降子序列): 遍历每一个数字x,若x>=vc
阅读全文
posted @ 2023-11-30 10:40 osir
阅读(22)
评论(0)
推荐(0)
最大连续子序列的和
摘要: 从左往右遍历每一个数字,并且记录和。如果当前的和比原本数字更大,则继续走。否则如果当前和比当前数字更小,那么当前和改为当前数字,从当前数字往后走接着遍历。
阅读全文
posted @ 2023-11-29 12:36 osir
阅读(9)
评论(0)
推荐(0)
质因数分解
摘要: #include <bits/stdc++.h> using namespace std; void solve(){ int n; cin>>n; map<int,int> prifac; for(int i=2;i<=n;i++){ int x=36; for(int j=2;j<=x/j;j+
阅读全文
posted @ 2023-11-23 13:10 osir
阅读(14)
评论(0)
推荐(0)
快速幂&矩阵快速幂
摘要: int quickpow(int x,int n,int p){ //o(logn) //x的n次方mod p int res=1; while(n){ if(n&1) res=res*x%p; x=x*x%p; n=n>>1; } return res; }
阅读全文
posted @ 2023-11-22 22:46 osir
阅读(10)
评论(0)
推荐(0)
线段树
摘要: ①建树 o(n) ②单点修改 o(logn) ③区间查询 o(logn) ④区间修改 o(logn) //线段树 #include <bits/stdc++.h> using namespace std; #define int long long #define lc p<<1 #define r
阅读全文
posted @ 2023-11-14 20:54 osir
阅读(11)
评论(0)
推荐(0)
2023年10月
树状数组
摘要:
阅读全文
posted @ 2023-10-05 14:07 osir
阅读(7)
评论(0)
推荐(0)
离散化
摘要: ①排序 ②去重 ③二分查找,编号 对vector离散化: 同理:
阅读全文
posted @ 2023-10-03 22:34 osir
阅读(6)
评论(0)
推荐(0)
上一页
1
2
3
4
5
6
下一页
公告