摘要: 找出最长公共子序列:最长公共子序列 把问题转换为求最长上升子序列 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 阅读(1) 评论(0) 推荐(0) 编辑
摘要: //洛谷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 阅读(0) 评论(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 阅读(0) 评论(0) 推荐(0) 编辑
摘要: 用vector模拟队列:贪心+二分--最后vct.size()则为最长子序列的长度 1.Lis(最长上升子序列): 遍历每一个数字x,若x>vct中最后一个数字,直接加入;否则lower_bound找到第一个>=x的数字,并替换为x; 2.Lnds(最长非降子序列): 遍历每一个数字x,若x>=vc 阅读全文
posted @ 2023-11-30 10:40 osir 阅读(0) 评论(0) 推荐(0) 编辑
摘要: 从左往右遍历每一个数字,并且记录和。如果当前的和比原本数字更大,则继续走。否则如果当前和比当前数字更小,那么当前和改为当前数字,从当前数字往后走接着遍历。 阅读全文
posted @ 2023-11-29 12:36 osir 阅读(0) 评论(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 阅读(0) 评论(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 阅读(0) 评论(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 阅读(0) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2023-10-05 14:07 osir 阅读(2) 评论(0) 推荐(0) 编辑
摘要: ①排序 ②去重 ③二分查找,编号 对vector离散化: 同理: 阅读全文
posted @ 2023-10-03 22:34 osir 阅读(0) 评论(0) 推荐(0) 编辑