高级课程
mozeli
这个作者很懒,什么都没留下…
展开
-
偷钻石(网络流)
传送门 #include<bits/stdc++.h> using namespace std; #define inf 0x3f3f3f3f const int maxn=205; int n,m,g[maxn][maxn],flow[maxn],pre[maxn]; bool bfs(int s,int t,int v){//搜索增广路,源点,汇点,顶点数 memset(pre,-1,sizeof(pre)); memset(flow,inf,sizeof(flow)); queue原创 2021-09-23 20:13:11 · 73 阅读 · 0 评论 -
最小割(最大流)
传送门 #include<bits/stdc++.h> using namespace std; #define inf 0x3f3f3f3f const int maxn=205; int n,m,g[maxn][maxn],pre[maxn],flow[maxn]; bool bfs(int s,int t,int v){ memset(pre,-1,sizeof pre); memset(flow,inf,sizeof flow); queue<int> q; q.pu原创 2021-09-23 19:55:58 · 60 阅读 · 0 评论 -
网络流 分房间(最大流)
传送门 #include<bits/stdc++.h> using namespace std; #define inf 0x3f3f3f3f const int maxn=205; int n,m,g[maxn][maxn],pre[maxn],flow[maxn]; bool bfs(int s,int t,int v){ memset(pre,-1,sizeof pre); memset(flow,inf,sizeof flow); queue<int> q; q.pu原创 2021-09-23 19:33:19 · 85 阅读 · 0 评论 -
hdu1532网络流(模板)
传送门 //从汇点到源点遍历路径,更新残留网络 #include<bits/stdc++.h> using namespace std; const int inf=0x3f3f3f3f; const int maxn=205; int n,m,g[maxn][maxn],pre[maxn],f[maxn];//pre[]记录路径(前驱节点),f[]记录最小剩余容量 bool bfs(int s,int t,int v){//搜索增广路,源点,汇点,顶点数 memset(pre,-1,s原创 2021-09-16 20:51:12 · 49 阅读 · 0 评论 -
铺地砖(状压dp)
传送门 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int mode=1e9+7; const int maxn=(1<<17)+5; ll dp[maxn<<1],*pre,*cur;//分别从前往后,从后往前 int t,n,m; int main() { int s; cin>>t; while(t--){ cin>>n>&g原创 2021-09-07 20:36:04 · 213 阅读 · 0 评论 -
集合划分(状压dp)
#include<bits/stdc++.h> using namespace std; const int maxn=(1<<16)+5; int n,a[20],dp[maxn],sum[maxn]={0};//dp[s]表示出现s集合,可行划分的总数 int c[maxn],ispri[1700]={1,1}; int main() { int t,s; scanf("%d",&t); for(int i=0;i<16;i++) c[1<<i]原创 2021-09-07 19:14:45 · 95 阅读 · 0 评论 -
hdu5418(同5691)
传送门 #include<bits/stdc++.h> using namespace std; #define inf 0x3f3f3f3f const int maxn=(1<<16)+5; int n,m,dp[maxn][20],g[20][20],c[maxn]; int main() { int t,S,u,v,w; for(int i=0;i<16;i++) c[1<<i]=i+1; scanf("%d",&t); while(t--)原创 2021-09-03 19:37:25 · 49 阅读 · 0 评论 -
hdu5691状压dp
传送门 状态转移 dp[s|(1<<(j-1))][j]=max(dp[s|(1<<(j-1))][j],dp[s][i]+ai*aj) 有虚假态 #include<bits/stdc++.h> using namespace std; #define inf 0x80000000 int dp[1<<20][20];//dp[i][j],i为最大1<<n的二进制数,表示这n个数的当前选择方案,j表示第j个数为结尾 int a[20],p[2原创 2021-09-03 11:56:35 · 58 阅读 · 0 评论 -
hdu6287可持久线段树+线性筛
传送门 #include<bits/stdc++.h> using namespace std; const int maxn=1e5+5; int n,m; int pri[maxn],vis[maxn],pos[maxn],c=0;//质数表,最大质因子及其序号 int tot=-1,ver[maxn]; struct st{ int l,r,s;//s为质因子出现次数 }tre[maxn<<8]; void init(){//线性筛 memset(pri,0,size原创 2021-09-02 17:12:05 · 53 阅读 · 0 评论 -
洛谷2617 动态可持久线段树
添加链接描述 #include<bits/stdc++.h> using namespace std; const int maxn=2e5+5; struct st{ int l,r,sum; }tre[maxn<<9]; struct op{ char s[2]; int x,y,z; }q[maxn]; int a[maxn],b[maxn]; int tot,ver[maxn]; int n,m,c; int ndl[maxn],ndr[maxn],cntl,cntr;原创 2021-08-31 21:04:29 · 61 阅读 · 0 评论 -
主席树(mex)
添加链接描述 #include<bits/stdc++.h> using namespace std; int n,m,t; const int maxn=2e5+5; struct st{ int l,r,mi; }tre[maxn<<5]; int tot,ver[maxn]; void pushup(int root){ st &rt=tre[root]; st &l1=tre[rt.l ]; st &r1=tre[rt.r ]; rt.mi原创 2021-08-31 14:59:47 · 94 阅读 · 0 评论 -
可持久线段树(主席树)模板
#include<bits/stdc++.h> using namespace std; const int maxn=1e5+5; int t,n,m; int tot; int ver[maxn]; struct st{ int l,r,sum; }tre[maxn<<5]; int build(int l,int r){ int root=++tot; tre[root].l =root; tre[root].r =root; tre[root].sum =0; r原创 2021-08-29 20:26:44 · 136 阅读 · 0 评论 -
洛谷3834主席树+离散化
添加链接描述 #include<bits/stdc++.h> using namespace std; const int maxn=2e5+5; int ver[maxn]; int tot,n,m; struct st{ int l,r,sum; }tre[maxn<<5]; int lsh[maxn],a[maxn]; int build(int l,int r){ int root=++tot; tre[root].l =root; tre[root].r =root原创 2021-08-29 20:25:42 · 82 阅读 · 0 评论