03 2020 档案
摘要:```#include#include#include#includeusing namespace std;const int N=210;int t,n;int col[N],A[N],len[N],dp[N][N][N]; //dp[i][j][k]代表消除第 i~j 块且区间最右边留下了 k 个与 j 颜色相同的方块的最大价值int solv(int l,int r,int last) {...
阅读全文
posted @ 2020-03-31 13:21
晴屿
摘要:``` #include using namespace std; const int N=2e5; int f[N]; int g[N]; int q[N]; int s1[7]; int m; //数量为a[1...6] //还是数量 //价值1~6 //变为体积 //然后价值都是1 //问能不能凑出体积为一半 int main() { while(cin>>s1[1]>>s1[2]>>s1[
阅读全文
posted @ 2020-03-31 13:19
晴屿
摘要:```//f[i,cnt] 表示前i个数字和为cnt #include#include#include#includeusing namespace std;const int N=110,M=200020;int hh=10000;//hh是我们的下标偏移量 int n,t,f[N][M],a[N],ans[N];void solve(){ f[1][a[1]+hh]=1;//a[1]必然...
阅读全文
posted @ 2020-03-31 13:18
晴屿
摘要:```#include#include#include #includeusing namespace std;#define int long longtypedef long long ll;const int N=200;int read(){ int res=0,ch,flag=0; if((ch=getchar())=='-') //判断正负 ...
阅读全文
posted @ 2020-03-30 20:50
晴屿
摘要:参考秦大佬的题解: https://www.acwing.com/solution/AcWing/content/1730/
阅读全文
posted @ 2020-03-30 20:47
晴屿
摘要:``` #include #include #include #include using namespace std; typedef long long ll; const int N=1e5,M=90000; const ll INF=1e15; int n,m,e; struct node{ int l,r,w; bool operator>1; build(u>1; if(k=l&&tr
阅读全文
posted @ 2020-03-29 22:08
晴屿
摘要:参考博客 https://ksmeow.moe/meal csps219 sol/
阅读全文
posted @ 2020-03-29 17:51
晴屿
摘要:```//对于每个元素,往前看N/2个//当前是i,前面是j//i-j+a[i]+a[j]=i+a[i]+a[j]-j//i是固定的,所以可以用滑动窗口优化,单调队列 #include#include#include#includeusing namespace std;const int N=2e6+10;int n;int w[N];int q[N];int main(){ cin>>n...
阅读全文
posted @ 2020-03-26 16:49
晴屿
摘要:``` //f[i,j,0],考虑了前i小时,且一共睡了j小时,且第i小时不睡觉的最大收益 //f[i,j,1],考虑了前i小时,且一共睡了j小时,且第i小时在睡觉的最大收益 //f[i,j,0]=max{f[i-1,j,0],f[i-1,j,1]} //f[i,j,1]=max{f[i-1,j-1,0],f[i-1,j-1,1]+w[i]} //第N小时不在睡觉的话 //f[1,1,0]=0,f
阅读全文
posted @ 2020-03-26 16:47
晴屿
摘要:``` #include #include #include #include using namespace std; const int N=4e5+10; int e[N],w[N],h[N],ne[N],idx; int ans; int n; int deg[N]; int d[N]; int dp[N]; void add(int a,int b,int c) { e[idx]=b;
阅读全文
posted @ 2020-03-26 11:42
晴屿
摘要:``` #include #include #include #include using namespace std; const int N=3010; int e[N],h[N],ne[N],idx; int f[N][2]; bool st[N]; void add(int a,int b) { e[idx]=b; ne[idx]=h[a]; h[a]=idx++; } int n,m;
阅读全文
posted @ 2020-03-25 18:21
晴屿
摘要:``` /* 10 180 10 90*2 2610 180 10 900*3-90 34200 2610 180 10 9000*4-900*2 423000 34200 2610 180 10 90000*5-9000*3 5040000 423000 34200 2610 180 10 900000*6-90000*4 */ #include #include #include #inclu
阅读全文
posted @ 2020-03-24 09:55
晴屿
摘要:``` #include #include #include #include #define int long long using namespace std; const int N=30000+10; const int mod=1000007; int a[N]; int read() { int res=0,ch,flag=0; if((ch=getchar())=='-') //判断
阅读全文
posted @ 2020-03-23 18:38
晴屿
摘要:``` #include #include #include #include using namespace std; const int N=300000+10; const int mod=1000007; //直接dp //dp[i]表示放了多少花 int dp[110]; int a[N]; int m,n; int main() { cin>>n>>m; for(int i=1;i>a
阅读全文
posted @ 2020-03-23 18:02
晴屿
摘要:``` #include #include #include #include using namespace std; const int N=300000+10; int dp[N]; int m,s,t; int main() { cin>>m>>s>>t; for(int i=1;i=10) dp[i]=dp[i-1]+60,m-=10; else dp[i]=dp[i-1],m+=4;
阅读全文
posted @ 2020-03-23 17:29
晴屿
摘要:``` #include #include #include #include using namespace std; const int N=1010; int a[N]; int sum; int main() { int t; cin>>t; while(t--) { int n; cin>>n; sum=0; int pos=0; for(int i=1;i>a[i]; sum+=a[i
阅读全文
posted @ 2020-03-21 21:04
晴屿
摘要:``` #include #include #include #include #include using namespace std; int read() { int res=0,ch,flag=0; if((ch=getchar())=='-') //判断正负 flag=1; else if(ch>='0'&&ch='0'&&ch0) f[u]+=f[v]; } } bool vis[N]
阅读全文
posted @ 2020-03-21 20:47
晴屿
摘要:``` #include #include #include #include using namespace std; const int N=2010; int a[N],f[N][N]; int read() { int res=0,ch,flag=0; if((ch=getchar())=='-') //判断正负 flag=1; else if(ch>='0'&&ch='0'&&ch<='
阅读全文
posted @ 2020-03-21 20:30
晴屿
摘要:一开始输出的必定为n,初始时,1~pos[n]都+1,只要tr[1].v 0,那么就说明,不存在位置大于等于pos[k]的炸弹 然后依次进行修改,处理1~q[n],如果tr[1].v include include include using namespace std; typedef long
阅读全文
posted @ 2020-03-21 17:11
晴屿
摘要:自己写的不知道为什么,degug一下午,还是t,吐了 然后参考大佬的博客https://www.jianshu.com/p/af3cc413d299
阅读全文
posted @ 2020-03-19 18:31
晴屿
摘要:```#include#include#include#include#includeusing namespace std;const int N=1e5+10;int tr[N][130],n,m,idx,ne[N],ed[N],cnt,cas=1;int vis[N];char str[N];void insert(char str[],int id){ int len=strlen(str...
阅读全文
posted @ 2020-03-19 12:04
晴屿
摘要:``` //ac自动机 可以优化成 trie图 #include #include #include #include using namespace std; const int N = 10010, S = 55, M = 1000010; int n; //tire 以每个节点结尾的单词数量 int tr[N * S][26], cnt[N * S], idx; //字符串 char str
阅读全文
posted @ 2020-03-19 10:51
晴屿
摘要:``` //将含有N个元素的一个集合分成M个子集,使得每个子集的最大值与最小值平方差的和最小。 #include #include #include #include using namespace std; typedef long long ll; const int maxn = 1e4+50; const int maxm = 5e3+50; ll dp[maxn][maxm] ,v[ma
阅读全文
posted @ 2020-03-18 18:11
晴屿
摘要:参考博客https://blog.csdn.net/qq_26572969/article/details/47155559
阅读全文
posted @ 2020-03-18 18:02
晴屿
摘要:```#include#include#include#includeusing namespace std;const int N=1e5;int val[N],sum[N],dp[N];int q[N],r,l;int getup(int r,int l) { return dp[r]-dp[l];}int getdown(int r,int l) { return sum[r]-...
阅读全文
posted @ 2020-03-18 17:44
晴屿
摘要:``` #include #include #include #include using namespace std; typedef long long ll; const int N= 500000+10; int q[N],l,r; ll sum[N],val[N]; ll dp[N]; int n,m; ll getdown(int j,int k) { return val[j+1]-
阅读全文
posted @ 2020-03-18 17:40
晴屿
摘要:``` //考虑在V个村庄中只建立【一个】邮局的情况,显然可以知道, //将邮局建立在中间的那个村庄即可。也就是在a到b间建立一个邮局, //若使消耗最小,则应该将邮局建立在(a+b)/2这个村庄上 //下面考虑建立【多个】邮局的问题,可以这样将该问题拆分为若干子问题, //在前i个村庄中建立j个邮局的最短距离, //是在前【k】个村庄中建立【j-1】个邮局的最短距离 与 //在【k+1】到第i个
阅读全文
posted @ 2020-03-18 16:36
晴屿
摘要:``` #include #include #include #include using namespace std; typedef long long ll; const int N=4e5+50; int q[N],l,r; ll sum[N],val[N]; ll dp[N]; int n,m; ll getdown(int j,int k) { return val[j+1]-val[
阅读全文
posted @ 2020-03-18 16:10
晴屿
摘要:``` #include #include #include #include using namespace std; const int N=1e5+10; int sum[N],dp[N]; int q[N]; inline double calc(int j,int i) { return (double)(sum[i]-sum[j])/(i-j); } int main() { int
阅读全文
posted @ 2020-03-18 14:02
晴屿
摘要:debug半天,也没找出错误,就是卡fread快读有点恶心, 参考博客https://blog.csdn.net/zyszlb2003/article/details/94427222 #include<stdio.h> #include<iostream> #include<string.h> #
阅读全文
posted @ 2020-03-18 13:25
晴屿
摘要:```#include#include#include#includeusing namespace std;const int MAX = 1000+10;//dp[i][j]:把前 i 个数分成 j 段后能得到的序列的最小权值和//dp[i][j] = min( dp[k][j-1] + cost[i] - cost[k] - sum[k] *(sum[i] - sum[k]) ) ;//su...
阅读全文
posted @ 2020-03-17 20:35
晴屿
摘要:```#include#include#include#includeusing namespace std;typedef long long ll;const int N=5e5+10;int n,m,c;int q[N];ll dp[N];ll sum[N];ll get_y(int j,int k){ return dp[j]+sum[j]*sum[j]-dp[k]-sum[k]*sum[...
阅读全文
posted @ 2020-03-17 19:41
晴屿
摘要:```//f[i]表示所有将前i个任务处理完的方案,划分方案//属性为花费最小值//表示最后一批,枚举上一批,当上一批到1时,那么最后一批就是2到i//上一批到2时,那么最后一批就是3到i,上一批最多到i-1//上一批到j,那么最后一批就是j+1到i //前面的花费为f[j] //令执行时间前缀和为sumt,启动时间前缀和为sumc//那么最后一部分的花费为sumt[i]*(sumc[i]-sum...
阅读全文
posted @ 2020-03-17 16:32
晴屿
摘要:参考文章:https://oierwanhong.cc/2020/03/16/CF1325E/ 每个数至多有个7约数,也就是每个数至多两个不同的质因数 如果某个数没有指数为奇数的质因子,那么它就是一个完全平方数,直接输出1 如果某个数只有1个指数为奇数的质因子,让这个质因子和"源点"1连无向边 某个
阅读全文
posted @ 2020-03-16 20:05
晴屿
摘要:参考博客:https://www.cnblogs.com/ZGQblogs/p/10679934.html
阅读全文
posted @ 2020-03-16 09:54
晴屿
摘要:```//f[i,j,f1,f2]//f1 和 f2 都是01数//1表示剩下的人是喜欢的//从j开始,长度为2^i个人,胜者组为f1,败者组为f2#include#include#include#includeusing namespace std;const int maxn = ((1>n>>k; for(int i=0; i>x; fans[x-1]=1; } //枚举i for(int...
阅读全文
posted @ 2020-03-16 08:34
晴屿
摘要:``` //贪心 //从初始值最小开始 //如果当前值有许多,那么就把花费最大的留下,其他的都加一个 //然后依次网上增加 #include #include #include using namespace std; typedef long long ll; const int INF=0x3f3f3f3f; priority_queueh; const int N=2e5+10; int n
阅读全文
posted @ 2020-03-16 08:24
晴屿
摘要:``` #include #include #include using namespace std; typedef long long ll; const int MOD=2520; ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); } ll lcm(ll a,ll b) { return a*b/gcd(a,b); } ll dp[30][MOD][
阅读全文
posted @ 2020-03-15 22:40
晴屿
摘要:```#include#include#include#include #define mem(a,b) memset(a,b,sizeof(a))#define inf 0x3f3f3f3ftypedef long long LL;const LL mod=1e9+7;const int M=13;using namespace std;const int N =1e5+100;LL dp[21...
阅读全文
posted @ 2020-03-15 21:57
晴屿
摘要:```//dp[i][j][0]表示i位数模13为j当前没有包含13并且最高位不为1的方案数;//dp[i][j][1]表示i位数模13为j当前没有包含13并且最高位为1的方案数;//dp[i][j][2]表示i位数模13为j当前包含13的方案数。#include#include#include#define N 15using namespace std;int bit[N],dp[N][N][...
阅读全文
posted @ 2020-03-15 21:28
晴屿
摘要:``` #include #include #include using namespace std; long long dp[30][30][3000]; int num[30]; long long dfs(int pos,int center,int sum,bool flag) { //如果遍历到最后以为了 if(pos==0) //判断和是否位0 return sum==0; if(s
阅读全文
posted @ 2020-03-15 20:55
晴屿
摘要:``` #include #include #include #include using namespace std; const int N=70; int a[N]; //设f(pos,det)f(pos,det)表示处理到pos位,当前detdet是多少的答案。 //detdet是这个二进制数0的数量减去1的数量 //当然需要注意的是,11的数量可能大于00的数量导致detdet为负,所以
阅读全文
posted @ 2020-03-15 16:23
晴屿
摘要:``` #include #include #include #include using namespace std; typedef long long ll; const int N = 35; ll n; ll f[N][30]; void init() { //处理一位的数字 for (int i = 0; i nums; while (n) nums.push_back(n % 10)
阅读全文
posted @ 2020-03-15 14:45
晴屿
摘要:``` //f[i,j]一共有i位数字,且最高位是j,而且不包括4和64的数的个数 //f[i-1,k] 表示次高位为k //如果合法,那么需要满足 j、k都不为4 jk不是62 #include #include #include #include using namespace std; const int N = 35; int f[N][10]; void init() { //处理一位的
阅读全文
posted @ 2020-03-15 14:21
晴屿
摘要:``` //一开始要思考:到底是增好还是减好 //然后用dp,忽略这个问题 //首先要明确的是,最终序列中的数字一定都是原序列中的数字 #include #include #include using namespace std; const int N=2000+20; int a[N]; int b[N]; int dp[N][N]; //dp[i,j],表示考虑前i个数变成单调,且最后一个数
阅读全文
posted @ 2020-03-14 11:33
晴屿
摘要:开始读题读了半天,还是参考了大佬的博客 https://blog.csdn.net/codeswarrior/article/details/81479291 有一群屌丝,每个屌丝有个屌丝值,如果他第K个上场,屌丝值就为a[i] (k 1),因为前面有k 1个人在他前面上台,可以把几个人拉进小黑屋来
阅读全文
posted @ 2020-03-12 16:46
晴屿
摘要:```//dp[i][j][0/1] 表示送完区间 [i, j] 后,且外卖员在 i/j 点 #include#include#include#includeusing namespace std;typedef long long ll;const int N=1100;const int inf=0x3f3f3f3f;struct node{ int x,b;}s[N];ll dp[N][N]...
阅读全文
posted @ 2020-03-12 15:22
晴屿
摘要:```#include#includeusing namespace std;const int N=110;int dp[N][N];int w[N];int n;int main(){ cin>>n; for(int i=1;i>w[i]; memset(dp,0,sizeof dp); for(int i=1;i<n-1;i++) dp[i][i+2]=w[i]*w[i+1]*w[i+2]...
阅读全文
posted @ 2020-03-12 14:56
晴屿
摘要:设dp[l][r][x][y]表示区间[l,r]左端染的色是x,右端染的色是y的方案数 其中x,y取0,1,2,分别表示不染色,染红色,染蓝色 1.l+1==r,那么它们一定就是一对匹配的括号,因为我们枚举的都是合理的情况,此时,只可能有四种情况,方案数均为1,即:dp[l][r][0][1] =
阅读全文
posted @ 2020-03-12 14:41
晴屿
摘要:枚举起点和终点,当起点和终点匹配时,dp[start][end]=dp[start+1][end 1]+2 然后枚举中间点
阅读全文
posted @ 2020-03-12 14:13
晴屿
摘要:```//dp[i][i]=1。也就是说每个舞会换件衣服//对于dp[i][j]://1.如果cos[i]=cos[j],dp[i][j]=dp[i][j-1],很明显i的衣服穿在最底,在j的时候就能拿出来再用//之后枚举中间点k,注意(i#include #includeusing namespace std;#define maxn 105#define inf 0x3f3f3f3fint a...
阅读全文
posted @ 2020-03-12 01:07
晴屿
摘要:问题 A: sciorz画画 题目描述 众所周知,sciorz会画画。某天,sciorz画了一个凸多边形,这个多边形的每个顶点都有一个权值a[i]。sciorz觉得这个凸多边形不够美丽,于是他决定在n个点之间连线,最终用n-3条不相交的线将这个凸n边形分割成n-2个三角形。sciorz认为,一个三角
阅读全文
posted @ 2020-03-09 09:43
晴屿
摘要:```#include #include #include #include #include using namespace std;const int MAXN = 250;int N; //点的个数,点的编号从1到Nbool Graph[MAXN][MAXN];int Match[MAXN];bool InQueue[MAXN],InPath[MAXN],InBlossom[MAXN];in...
阅读全文
posted @ 2020-03-07 11:51
晴屿
摘要:```#pragma GCC optimize (3,"inline","Ofast")#include using namespace std;typedef long long ll;bool Finish_read;templateinline void read(T &x) { Finish_read=0; x=0; int f=1; char ch=getchar(); while(!i...
阅读全文
posted @ 2020-03-07 11:36
晴屿
摘要:```#pragma GCC optimize (3,"inline","Ofast")#include using namespace std;typedef long long ll;bool Finish_read;templateinline void read(T &x) { Finish_read=0; x=0; int f=1; char ch=getchar(); while(!i...
阅读全文
posted @ 2020-03-07 11:21
晴屿
摘要:```#include#include#include#includeusing namespace std;const int N = 1000+10;const int M = 500+10;int n,m;int map[N][M],vlink[M],link[M][N],max_cap;bool vis[M];int path(int s) { for(int i=0; i>1; //...
阅读全文
posted @ 2020-03-07 10:02
晴屿
摘要:``` #include #include #include #include using namespace std; #define N 510 int vis[N], match[N], maps[N][N], n, ans; void floyd() { for(int k=1; k<=n; k++) for(int i=1; i<=n; i++) for(int j=1; j<=n; j
阅读全文
posted @ 2020-03-06 21:33
晴屿
摘要:```#include #include using namespace std;typedef long long int ll;const int maxn=101010;int e[maxn],ne[maxn],h[maxn],idx;int N, M;void add(int a,int b){ e[idx]=b; ne[idx]=h[a]; h[a]=idx++;}bool vis[ma...
阅读全文
posted @ 2020-03-06 21:28
晴屿
摘要:```#include#include#include#includeusing namespace std;#define N 10100int vis[N], h[N], used[N], maps[1510][1510], n, ans;int e[N],ne[N],idx; void add(int a, int b){ e[idx]=b; ne[idx]=h[a]; h[a]=idx++...
阅读全文
posted @ 2020-03-06 21:17
晴屿
摘要:```#include#include#include#include#includeconst int MAXN= 500000;//最大顶点数const int MAXM = 11000;//最大边数const int INF=0x3f3f3f3f;using namespace std;bool used[MAXN];int linker[MAXN],index[500][500];int ...
阅读全文
posted @ 2020-03-06 20:59
晴屿
摘要:```//HK算法模板题 #include #define inf 0x3f3f3f3fconst int maxn=3030;using namespace std;int e[maxn*maxn],ne[maxn*maxn],h[maxn*maxn],idx;struct node { double x,y,v;} a[maxn];int lx[maxn],ly[maxn],dx[maxn]...
阅读全文
posted @ 2020-03-05 21:27
晴屿
摘要:```//把矩阵按行和列缩点,格子为1的就在所在行列加边//然后二分图求最大匹配,如果是n,代表可行,小于n就输出-1#include#includeusing namespace std;typedef long long ll;const int N=100+10;int g[N][N];int match[N];bool used[N];int n;bool find(int u) { fo...
阅读全文
posted @ 2020-03-05 21:02
晴屿
摘要:```#include#include#include#includeusing namespace std;const int maxn = 1e4+5;int G[105][105];int a[maxn],b[maxn];int match[105];int st[105];int n,m,ans;bool find(int u) { for(int i = 1; i>n>>m>>k) { ...
阅读全文
posted @ 2020-03-04 17:31
晴屿
摘要:```#include#include#includeusing namespace std;const int MAXN = 2e5;int match[MAXN], st[MAXN];int n,m,p;int e[MAXN],ne[MAXN],idx,h[MAXN];void add(int a,int b){ e[idx]=b; ne[idx]=h[a]; h[a]=idx++; }boo...
阅读全文
posted @ 2020-03-04 16:16
晴屿
摘要:```//只有出现墙的时候,才会出现一行/列多个点的情况//那么可以考虑缩点,以行为例//如果某一行没有墙,那么这一列整体所成一个点//如果有墙,那么把没有墙的部分缩成一个点//当换行时,记得点数++ #include#include #define INF 0x3f3f3f3f#define LL long longconst int N=1000+5;using namespace std;i...
阅读全文
posted @ 2020-03-04 14:55
晴屿
摘要:```#include #include using namespace std;const int M=100000+5;int n;int h[M*2],mx[M*2],my[M*2];int vis[M];int e[M*2],ne[M*2],idx;int read(){ int res=0,ch,flag=0; if((ch=getchar())=='-') ...
阅读全文
posted @ 2020-03-03 16:19
晴屿
摘要:```//构建二分图#include #include typedef long long ll;using namespace std;const int N=155;const int INF=0x3f3f3f3f;struct Edge { int from,to;} edge[N*N];int tot,n,m;int read() { int res=0,ch,flag=0; if((ch...
阅读全文
posted @ 2020-03-03 15:59
晴屿
摘要:```#include using namespace std;const int maxn = 505;bool g[maxn][maxn], vis[maxn];int match[maxn];int val[maxn], keep[maxn];int a[maxn], b[maxn], c[maxn], d[maxn];int t, n, h, m;bool dfs(int u) { for...
阅读全文
posted @ 2020-03-03 15:41
晴屿
摘要:```#include#includeusing namespace std;const int N=1e5;const int maxn=1e3;int e[N],ne[N],h[N],idx;void add(int a,int b){ e[idx]=b; ne[idx]=h[a]; h[a]=idx++;}int n,m,xN,yN;int link[N],num[maxn][maxn],m...
阅读全文
posted @ 2020-03-03 15:24
晴屿
摘要:```#include#includeusing namespace std;typedef long long LL;const int N = 5e3+10;int map[110][110];int match[N], st[N];int n, m, k;bool dfs(int x){ for (int i = 1;i <= m;i++) { if (map[x]...
阅读全文
posted @ 2020-03-03 15:03
晴屿
摘要:```#include#include#includeusing namespace std;const int N=1e5;//点数的最大值int e[N],ne[N],idx,h[N];int K,M,N;void init() { idx=0; memset(h,-1,sizeof(h));}void addedge(int a,int b) { e[idx]=b; ne[idx]=h[a]...
阅读全文
posted @ 2020-03-03 14:56
晴屿
摘要:```#include #define PI acos(-1.0)#define E 1e-9#define INF 0x3f3f3f3f#define LL long longconst int N=1000+5;using namespace std;int n;bool vis[N];//vis[i]表示是否在交替路中int match[N];//存储连接点int e[N],ne[N],h[...
阅读全文
posted @ 2020-03-03 14:17
晴屿
摘要:```//首先将池塘舍去,然后将所有 i+j 为偶数的点当作 x,//将所有 i+j 为奇数的点当作 y,//然后直接拿 (x,y) 寻找增广路,//通过上下左右进行查找匹配,//再通过 link[x1][y1]=(x2,y2) 来记录匹配点#include#define LL long longconst int N=1000+5;const int dx[]= {-1,1,0,0};const...
阅读全文
posted @ 2020-03-03 11:20
晴屿
摘要:```//判断每个气球需要多少次才能扎破//大于k的,那么就不满足条件//可以看作最小点覆盖问题//分为两个集合,横坐标集合,纵坐标集合//然后每个点的坐标在这两个集合中且两点之间有连线//然后就是求最小点覆盖 #include#include#include#include#include#include#includeusing namespace std;const int maxn = 1...
阅读全文
posted @ 2020-03-03 10:51
晴屿
摘要:```#include using namespace std;const int N=510,M=100010;int e[M],ne[M],h[N],idx,ans;bool st[N];int n,m,num,a;int match[N];void add(int a,int b) { e[idx]=b,ne[idx]=h[a],h[a]=idx++;}int find(int x) { f...
阅读全文
posted @ 2020-03-02 22:50
晴屿
摘要:```//匈牙利求最大匹配//从左边每个非匹配点出发,做一遍增广,标记所有经过的点,//左边所有未被标记的点,和右边所有被标记的点,加起来就是要构造的方案//左边所有的非匹配点,都被标记了,//右边所有的非匹配点,一定没有被标记//对于每一个匹配边,左右两点要么同时被标记,要么同时不被标记//那么左边剩下的未被标记的点,一定是匹配点//右边所有被标记的点,都是匹配点//不在匹配中的情况:左边的非匹...
阅读全文
posted @ 2020-03-02 22:29
晴屿
摘要:```#include #include #include #include using namespace std;const int N =1e5;int n;int h[N], e[N], ne[N], idx;int match[N];bool st[N];void add(int a, int b) { e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ...
阅读全文
posted @ 2020-03-01 00:06
晴屿