随笔分类 -  二分匹配&&二分图

摘要:匈牙利: #include<iostream> #include<cstdio> #include<algorithm> #include<queue> #include<iomanip> #include<cstring> using namespace std; typedef long lon 阅读全文
posted @ 2020-06-20 10:09 晴屿 编辑
摘要:#include<iostream> #include<cstdio> #include<algorithm> #include<queue> #include<iomanip> #include<cstring> using namespace std; typedef long long ll; 阅读全文
posted @ 2020-06-04 00:28 晴屿 编辑
摘要:#include<bits/stdc++.h> #pragma GCC optimize(3) using namespace std; const int N=1009,M=100009; int n,m,ans,ord,q[M],pre[N]; int ql,qr,dfn[N],lk[N]; i 阅读全文
posted @ 2020-06-02 23:50 晴屿 编辑
摘要:#pragma GCC optimize (3,"inline","Ofast") #include <bits/stdc++.h> using namespace std; typedef long long ll; const ll N=505; const ll inf=1e18; ll n, 阅读全文
posted @ 2020-05-30 11:38 晴屿 编辑
摘要:``` //图是不一定联通的 //于是,我们就可以将整张图切分成许多分开的连同子图来处理 //每一条边所连接的点中,至少要有一个被选中 //每一条边所连接的两个点,不能被同时选中 //所以:每一条边都有且仅有一个被它所连接的点被选中 //因为要处理的是一个连通图,所以,对于这一个图的点的选法,可以考虑到相邻的点染成不同的颜色 // 于是,对于一个连通图,要不就只有两种选法(因为可以全部选染成一种色 阅读全文
posted @ 2020-05-13 14:47 晴屿 编辑
摘要:``` #include #define f first #define s second using namespace std; typedef long long ll; const int N=300005; typedef pair P; int n,tot,t,V; map mp; map,int> mp2; vector G[N]; int match[N]; bool used[N 阅读全文
posted @ 2020-04-12 17:38 晴屿 编辑
摘要:```#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 晴屿 编辑

点击右上角即可分享
微信分享提示