随笔分类 - 模板
摘要:顾名思义,二分图就是能将图分为两部分的图。这两部分满足只有不同部分间有边,同一部分内没边。这样的图存在许多优美的性质。然后大概就是下一次模拟赛再遇到二分图就不能拿没学过背锅了。 判定 直接定义法,DFS/BFS尝试给图染色。要求相邻点色不同。如果无法达到这种状态说明该图不是二分图。 模型 这里只着重
阅读全文
摘要:用于计算若干个矩形的并的面积或周长及其延伸出来的问题。思想形象点来说大概就是将二维平面的某一维离散化后上线段树,然后按照一定顺序(一般是从小到大)扫描,同时维护树上信息(一般是当前区间内图形与扫描线交的长度)。 比普通线段树特殊的几点: 1.一般不需要特定的query函数,一般直接取根节点的值即可;
阅读全文
摘要:高维空间操作 例题 二维平面操作 #include<bits/stdc++.h> using namespace std; typedef double db; const int maxn=2e5+10,maxk=2; const db e=0.75;//重构系数 int n,lans; int
阅读全文
摘要:根据函数的单调性与函数间的交点,维护/求若干条线段/直线在某个位置的最值,可用于优化斜率优化dp 模板题 求若干条线段在某个横坐标上的最大值,区间修改单点查询动态开点版 #include<bits/stdc++.h> using namespace std; const int maxn=1e5+1
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; const int maxn=1e6; int n,m; int to[maxn<<1],nxt[maxn<<1],h[maxn],tot;//建原图 inline void adde(int x,int y)
阅读全文
摘要:(前言:看不懂的代码,听不懂的算法,记记板子就好了,反正遇到也想不出来,也不会打awa) Dinic求最小割最大流 代码 #include<bits/stdc++.h> using namespace std; const int maxn=5010,inf=0x3f3f3f3f; typedef
阅读全文
摘要:Splay #include<bits/stdc++.h> using namespace std; const int maxn=1e6+1e5; struct splay{ int fa,ch[2],val,cnt,siz; }t[maxn]; int root,tot,xx,n,opt,m;
阅读全文
摘要:ST表 #include<bits/stdc++.h> using namespace std; const int maxn=5e5+10,hh=32; int n,m,s,a,b; int tot,to[2*maxn],nxt[2*maxn],h[maxn]; void adde(int x,i
阅读全文
摘要:#include<bits/stdc++.h> #define int long long using namespace std; const int maxn=110,maxm=110,m=1e9+7; int n,p,sz; struct mat{ int a[maxn][maxm]; mat
阅读全文
摘要:哈希 略 KMP 求next数组 ne[1]=0; for(int i=2,j=0;i<=n;i++){//i表示当前搜索位置,不回溯,j扫描前缀 while(j&&p[i]!=p[j+1]) j=ne[j]; if(p[i]==p[j+1]) j++; ne[i]=j; } example AC自
阅读全文
摘要:高斯消元 const double zero=1e-6;//注意精度 int n; double a[maxn][maxn]; int gs(){ int c,line,pai=0; for(c=1;c<=n;c++){ line=c; for(int i=1;i<=n;i++){//找第i排第c项
阅读全文

浙公网安备 33010602011771号