自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 旋转数组<vector>

【代码】旋转数组<vector>

2024-03-22 00:05:22 83

原创 数组递归建树与指针递归建树&&二叉搜索树的构造

【代码】数组递归建树与指针递归建树&&二叉搜索树的构造。

2024-03-21 14:58:04 205

原创 树连剖分求LCA

【代码】树连剖分求LCA。

2024-03-16 13:18:40 350

原创 高精度乘法

使用于高精度与int/long long乘积 ACWING。

2024-03-09 20:38:02 309

原创 【无标题】

动态的n阶乘矩阵。

2024-03-05 19:42:52 330 1

原创 数位DP呀呀

#include<bits/stdc++.h>using namespace std;int f[1005][3];//lm=1为有限制int a[1005];int dfs(int pos,int st,int lm){ if(pos==0) return st==2; if(f[pos][st]!=-1&&lm==0) return f[pos][st]; int x=lm?a[pos]:9; int ans=0; for(int i=0;i<

2022-04-08 13:58:45 236 1

原创 二分模板KKK

最大中求最小int l;int r;while(l<r){ int mid=l+r>>1; if(check(mid)) { r=mid; } else { l=mid+1; }}//l r都可,两者相等最小中求最大int l;int r;while(l<r){ int mid=l+r>>1; if(check(mid)) {

2022-04-04 21:06:21 127 1

原创 PTA树的遍历(递归+模拟)

#include<bits/stdc++.h>using namespace std;const int maxn=37;int zx[maxn];int hx[maxn];int n;struct node{ int l; int r;};node pp[maxn];//la,ra表示后序int build(int la,int ra,int lb,int rb){ if(lb>rb) return 0; int root

2022-04-02 15:16:10 517

原创 STRING delete 指定字符

#include<bits/stdc++.h>using namespace std;string tmp;int main(){ string A; string B; getline(cin,A); getline(cin,B); for(int i=0;i<B.size();i++) { tmp.clear(); tmp+=B[i]; int n=tmp.size();

2022-04-01 16:38:18 445

原创 线段树模板

#include<bits/stdc++.h>using namespace std;int a[1000005];int sum[1000005*4];int lazy[1000005*4];int n,m;void push_down(int rt,int l,int r){ if(lazy[rt]!=0) { int mid=(l+r)>>1; lazy[2*rt]+=lazy[rt]; lazy[2

2022-03-30 19:09:29 225

原创 无向图染色问题 DFS 剪枝 回溯

#include<bits/stdc++.h>using namespace std;int known[101][101];int p[101][101];int n,m;int res=INT_MAX;void dfs(int x,int total){ if(total>=res) return; if(x==n+1){ res=min(total,res); return; } for(int i=1;i<=total;i++){ int

2022-03-30 17:34:19 142

原创 POJ1724

#include<cstdio>#include<cstring>#include<algorithm>#include<queue>using namespace std;int n,k;struct node{ int to; int next; int w; int l; node(){} node(int a,int b,int c,int d):to(a),next(b),w(c),l(d

2022-03-09 11:02:03 66

原创 森森快递丫

线段树+贪心算法(区间修改)#include<bits/stdc++.h>using namespace std;int minn[200005*4];int arr[200005];int lazy[200005*4];void push_down(int rt){ if(!lazy[rt]) return; lazy[2*rt]+=lazy[rt]; lazy[2*rt+1]+=lazy[rt]; minn[2*rt]-=lazy

2022-02-05 15:14:30 406

原创 强连通分量缩点 POJ 2186

#include <cstdio>#include <iostream>#include <algorithm>#include <cstring>#include <string>#include <stdlib.h>#include <vector>#include <queue>#include <cmath>#include <stack>#include &l

2021-10-07 11:48:06 101

原创 hdu2222 AC自动机

#include <stdlib.h>#include <string.h>struct Node{ int cnt;//是否为该单词的最后一个结点 Node *fail;//失败指针 Node *next[26];//Trie中每个结点的各个节点 }*queue[500005];//队列,方便用BFS构造失败指针 char s[1000005];//主字符串 char keyword[55];//需要查找的单词 Node *root;//头结点 void

2021-07-27 01:09:57 75

原创 线段树加树链剖分解决树上问题

#include<bits/stdc++.h>using namespace std;const int maxn=1e5+5;int top[maxn],size[maxn],son[maxn],fa[maxn],dep[maxn];int id[maxn];int w[maxn];int rev[maxn];int Sum,Max;struct node{ int to node(int a) { to=a; }};vec

2021-07-25 11:25:18 99

原创 树上点分治模板题p3806

// luogu-judger-enable-o2#include <cstdio>#include <cstring>#include <algorithm>using namespace std;#define inf 999999999 int n,m,len=0,Size;struct node{int x,y,z,next;};node e[20010];int first[10010];int root,ms,size[10010],ms

2021-07-22 15:53:08 71

原创 主席树 求区间第k小问题

#include<bits/stdc++.h>using namespace std;vector<int> v;const int maxn=2e5+5;struct node{ int l,r,sum;}hjt[maxn*40];int cnt,root[maxn];int a[maxn];void insert(int l,int r,int pre,int &now,int p){ hjt[++cnt]=hjt[pre];

2021-07-20 18:05:06 58

原创 马拉车算法 求回文

#include<bits/stdc++.h>using namespace std;const int MAXN = 110005;string expand(string s){ string str="*#"; for(int i=0;i<s.size();i++) { str+=s[i]; str+='#'; } return str;}string man(string s){ stri

2021-07-19 11:25:34 74

原创 二分图的最大匹配经典例题 hdu4185

#include"stdio.h"#include"string.h"#include"stdlib.h"#include"vector"using namespace std;#define N 605#define M 6005vector<int>g[M];int id[N][N],cnt;int mark[M],link[M];int dir[4][2]={0,1,0,-1,-1,0,1,0};char str[N][N];int find(int k){

2021-07-18 11:37:06 190

原创 KMP最小循环节 next数组的应用

#include#include#includeusing namespace std;const int MAXN = 1000005;int nxt[MAXN];char a[MAXN];void get_next() {int i = 0, j = -1;nxt[0] = -1;int len = strlen(a);while (i < len) {if (j == -1 || a[i] == a[j]) {i++, j++;nxt[i] = j;}else {

2021-07-17 13:07:01 98

原创 八数码问题(BFS+康托展开)

#include<stdio.h>#include#includeusing namespace std;typedef struct nn{char way;//记录路径int fath;//记录父节点}node1;typedef struct nod{int aa[10];int n,son;//n为9在aa中的位置}node2;int dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}},fac[10];node1 Node[370000

2021-07-17 12:54:51 239

原创 KMP算法

#include<bits/stdc++.h>#define ll long long#define R register int#define inf 0x3f3f3f3f#define mod 1000000007;using namespace std;inline ll read(){ll s=0,w=1;char ch=getchar();while(ch<‘0’||ch>‘9’){if(ch==’-’)w=-1;ch=getchar();}while(

2021-07-14 10:07:12 705 1

原创 倍增ST表

先打表再处理达到O(1)复杂度#include<bits/stdc++.h>using namespace std;typedef long long ll;const ll N=100005;ll a[N];ll dp[N][100];ll n;void st(){for(int i=1;i<=n;i++){dp[i][0]=a[i];}for(int j=1;(1<<j)<=n;j++){for(int i=1;i+(1<<

2021-07-13 17:24:21 67

原创 树链剖分(求LCA

#include<bits/stdc++.h>using namespace std;const int maxn=500003;vector s[maxn];int f[maxn];int d[maxn];int size[maxn];int top[maxn];int son[maxn];void dfs1(int x,int father){size[x]=1;d[x]=d[father]+1;son[x]=0;f[x]=father;for(int i=0;

2021-07-12 19:25:04 143

原创 2021-04-26

割点算法#include <iostream>using namespace std;int index;int num[9],low[9];int flag[9];int e[9][9];int root;int n,m;void dfs(int cur,int father){ int child=0; index++; num[cur]=index; low[cur]=index; for(int i=1;i<=n;i++)

2021-04-26 11:55:50 63 1

原创 复习小结--小康迷糊了--21.4.21

小康迷糊了的复习小结1.字典树2.线段树3.KMP算法4.字符串哈希5.二分图匹配6.最长递增子序列7.最长公共子串/子序列8.拓展欧几里得9.快速幂10.组合数学问题(卡特兰数)11.树的直径12.最短路问题13.最小生成树14.并查集15.欧拉回路16.连通块问题17.多源bfs问题18.差分,二分19.前缀和1.字典树模板#include <bits/stdc++.h>using namespace std;const int N=27;st

2021-04-21 12:38:24 705 9

空空如也

空空如也

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

TA关注的人

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