代码模板
细雨欣然
孤单是一个人的狂欢
展开
-
kd-tree
#include<bits/stdc++.h>#define alpha (1.130/2)#define INF 0x3f3f3f3fusing namespace std;typedef long long ll;const int DEM=2;const int maxn=1000010;int n,m,now,ans,root,points;queue<...原创 2019-11-14 23:33:11 · 207 阅读 · 0 评论 -
半平面交
#include <cstdio>#include <cmath>#include <iostream>using namespace std;#define eps 1e-8const int MAXN=10017;int n;double r;int cCnt,curCnt;//此时cCnt为最终切割得到的多边形的顶点数、暂存顶点个数str...原创 2019-11-01 23:52:20 · 163 阅读 · 0 评论 -
凸包 极角排序
const int maxn=1005;struct point{ int x; int y; point(){} point(int xx,int yy):x(xx),y(yy){} bool friend operator <(const point &a,const point &b){ if(a.x==b....原创 2019-10-31 22:49:36 · 311 阅读 · 0 评论 -
KM 二分图匹配
#include <bits/stdc++.h>const int maxn = 305;const int INF = 2e9;int match[maxn],lx[maxn],ly[maxn],slack[maxn];int G[maxn][maxn];bool visx[maxn],visy[maxn];int n,nx,ny,ans;bool findpath(...原创 2019-10-29 09:26:21 · 144 阅读 · 0 评论 -
高斯消元
#inlcude<bits/stdc++.h>using namespace std;const int maxn=105;double a[maxn][maxn];double x[maxn];void gauss(int n,int m){ int i=0,j=0,k,r,c; while(i<n&&j<m) {...原创 2019-08-07 11:19:44 · 95 阅读 · 0 评论 -
费用流
#include<bits/stdc++.h>using namespace std;const int maxn=100005;const int inf=20000005;struct edge{ int u,v,f,c,w;};struct shu{ int id,sum; friend bool operator <(shu a,shu b) ...原创 2019-08-07 11:24:09 · 100 阅读 · 0 评论 -
带修莫队
#include<bits/stdc++.h>using namespace std; typedef long long ll;int n,m,l,r,sz,a[350005];int flag[1000005]={0},Ans[50005]={0},vis[50005]={0},last[50005],ans,now,tot=0,top=0;struct shu{...原创 2019-08-07 11:25:12 · 189 阅读 · 0 评论 -
并查集
#include<bits/stdc++.h>using namespace std;typedef long long ll;const int maxn=1000005;int pa[maxn];int find(int x){return pa[x]==x?x:pa[x]=find(pa[x]);}void un(int x,int y){ int p...原创 2019-08-07 11:26:29 · 75 阅读 · 0 评论 -
倍增lca
#include<cstdlib>#include<iostream>#include<cstdio>#include<cstring>#include<vector>using namespace std;const int maxn=200005;int n,m,fa[maxn][25],deep[maxn];int...原创 2019-08-07 11:27:55 · 134 阅读 · 0 评论 -
线性基
#include<bits/stdc++.h>using namespace std;typedef long long ll;struct LB{ long long b[65],nb[65]; int num; LB() { memset(b,0,sizeof(b)); memset(nb,0,sizeof(n...原创 2019-08-07 11:31:27 · 103 阅读 · 0 评论 -
线段树
#include<bits/stdc++.h>using namespace std;int w[550005],n,m;void build(int k,int l,int r){ if(l==r) return; int mid=(l+r)>>1; build(k<<1,l,mid); build(k<<1|1,mid+1,r...原创 2019-08-07 11:36:26 · 81 阅读 · 0 评论 -
2进制trie树
#include<cstdlib>#include<cstdio>#include<cstring>#include<iostream>#include<vector>using namespace std;const int maxn=250005;struct edge{ int u,v,w,next;}e...原创 2019-08-09 15:25:36 · 172 阅读 · 0 评论 -
数学模板
#include<bits/stdc++.h>using namespace std;typedef long long ll;const int maxn=100005;const ll mod=100000007; //gcd ll gcd(ll x,ll y){return x==0?y:gcd(y%x,x);}//扩展欧几里得 ax+by=gcd(a,b)的解...原创 2019-08-09 15:26:54 · 279 阅读 · 0 评论 -
矩阵树定理
#include <bits/stdc++.h>using namespace std;#define maxn 90#define int long long #define mod 1000000000int n,m,f[maxn][maxn];int tot,Map[maxn][maxn];void add(int x,int y){ if(x>y...原创 2019-08-07 11:19:12 · 213 阅读 · 0 评论 -
马拉车
#include<bits/stdc++.h> using namespace std; char a[200005],ch[5],b[500005]; int d[500005]; int main() { while(~scanf("%s",a)) { int n=0,m; m=strlen(a); b[0]='&'; fo...原创 2019-08-07 11:18:36 · 102 阅读 · 0 评论 -
最小割树
#include<bits/stdc++.h> using namespace std;typedef long long ll;const int maxn=1005;const ll inf=20000000000005ll;struct edge //树上的边 { int u,v,next; ll w;}e[maxn*10];int f[maxn],cnt...原创 2019-08-08 11:55:55 · 107 阅读 · 0 评论 -
最小表示法
#include<bits/stdc++.h> using namespace std; char a[105],b[105]; int n; set<string>q; int getmin() { int i=0,j=1,len=strlen(a),k=0; while(i<len&&j<len&&k&...原创 2019-08-08 11:56:25 · 171 阅读 · 0 评论 -
最短路径树
#include<iostream>#include<cstdio>#include<vector>#include<cstdlib>#include<queue>using namespace std;const int maxn=105;const int maxm=3005;const int inf=2000000...原创 2019-08-08 11:56:56 · 241 阅读 · 0 评论 -
主席树(可持久化线段树)
#include<iostream>#include<algorithm>#include<cmath>#include<cstdlib>#include<cstdio> using namespace std;const int maxn=1e6+10;//root数组代表第i颗树的根 //插入和查询都是 两棵树同步走相...原创 2019-08-08 11:57:45 · 101 阅读 · 0 评论 -
支配树
#include<bits/stdc++.h> using namespace std;const int N = 200010;struct Node{int to,next;};//边 int n,m,dfn[N],clo,rev[N],f[N],semi[N],idom[N];// idom[x]是支配树上x的父亲 dfn[x]是x的拓扑序 //n个点m条边,n为...原创 2019-08-08 11:58:48 · 120 阅读 · 0 评论 -
匈牙利算法
#include<bits/stdc++.h> using namespace std;const int maxn=1010005;struct edge{ int v,next;}e[maxn*10];int f[10005],mx[maxn],state[maxn],fa[maxn]={0},n,cnt=0,T=0;void add(int u,int ...原创 2019-08-08 11:59:25 · 128 阅读 · 0 评论 -
求区间内最大(最小)子区间的线段树
#include<bits/stdc++.h>using namespace std;typedef long long ll;struct shu{ int l,r; ll w,lw,rw,ww;}w[100000];void up(int k,int l,int r){ int mid=(l+r)/2; int lk=k<&l...原创 2019-08-08 16:40:23 · 272 阅读 · 0 评论 -
珂朵莉树
#include <bits/stdc++.h>using namespace std; typedef long long ll;const int mod7 = 1e9 + 7;const int maxn = 1e5 + 7; ll pow(ll a, ll b, ll mod){ ll res=1; for(a%=mod;b;a=a*a%mod,b...原创 2019-08-07 11:12:39 · 228 阅读 · 0 评论 -
CDQ分治
#include<bits/stdc++.h> using namespace std;typedef long long ll;const int maxn=1000005;struct shu{ int x,id,y; ll ans; friend bool operator <(shu a,shu b) { ret...原创 2019-08-07 11:14:33 · 98 阅读 · 0 评论 -
floyed
#include<iostream>#include<cstdio>#include<cstdlib>#include<cstring>#include<algorithm>using namespace std;const int maxn=405;const int inf=4000005;int d1[maxn][m...原创 2019-08-07 11:15:12 · 219 阅读 · 0 评论 -
KMP
#include<bits/stdc++.h> using namespace std; int fail[10005],n,m,T; char a[1000005],b[10005]; void getnext() { fail[0]=-1; for(int i=0;i<m;i++) { int k=fail[i]; if(k!=-1&...原创 2019-08-07 11:15:35 · 111 阅读 · 0 评论 -
spfa
#include<iostream>#include<cstdio>#include<vector>#include<cstdlib>#include<queue>using namespace std;const int maxn=105;const int maxm=3005;const int inf=2000000...原创 2019-08-07 11:16:14 · 98 阅读 · 0 评论 -
平衡树
#include<bits/stdc++.h>using namespace std;const int maxn=100005;int a[maxn],ch[maxn][2],fa[maxn],root,n,s[maxn];void up(int x){ s[x]=s[ch[x][0]]+s[ch[x][1]]+1;}void link(int x,int ...原创 2019-08-07 11:17:14 · 74 阅读 · 0 评论 -
莫队
#include<bits/stdc++.h>using namespace std; typedef long long ll;int n,m,l,r,sz,a[100005];int flag[100005]={0},Ans[100005]={0},ans;struct shu{ int l,r,id; friend bool operator <(shu...原创 2019-08-07 11:18:03 · 186 阅读 · 0 评论 -
中国剩余定理
#include<iostream>#include<cstdlib>#include<cstdio>#include<algorithm>#include<cmath> using namespace std;typedef long long ll;ll n;ll a,b,x,y,d,A,B;void exgcd...原创 2019-08-08 11:54:01 · 117 阅读 · 0 评论