03 2014 档案
摘要:#include #include #include #include using namespace std;#define maxn 1000#define INF 100000struct Edge{ int from, to, cap, flow;};int n, m, s, t;vecto...
阅读全文
摘要:#include #include #include #include using namespace std;#define maxn 1500#define INF 100000struct Edge{ int from, to, cap, flow;};int n, m, s, t;ve...
阅读全文
摘要:#include #include #include #include using namespace std;#define maxn 230#define INF 100000struct Edge{ int from, to, cap, flow;};int n, m, s, t;vector...
阅读全文
摘要:#include #include #define maxn 1001000int id[maxn],p[maxn];bool vis[maxn];int find(int x){ if(p[x]==x) return x; else return p[x]=find(p[x]);}vo...
阅读全文
摘要:原图中相邻点两两连边,容量为1,源点连接狼的节点,容量为INF,羊的节点连接汇点,容量为INF,这样求最小割就可以了。#include #include #include #include using namespace std;#define maxn 50000#define INF 10000...
阅读全文
摘要:题意:求一个序列最长上升子序列的长度以及有多少个最长上升子序列。#include #include #include #include using namespace std;#define maxn 10000#define INF 100000struct Edge{ int from, ...
阅读全文
摘要:题意:在一个网络中求最大流和一条流量最大的路的流量的比值。主要是求最大流量的路,深搜一遍,数组q[ i ]表示从s到i点的最大流量,不断更新即可。#include #include #include #include using namespace std;#define maxn 1500#def...
阅读全文
摘要:#include #include #include using namespace std;const int N=500;const int MAXE=20000000;const int inf=10&&d[u]+edge[j].w=k) { ans+=(k...
阅读全文
摘要:题意 二维空间上有一些点,每个点有一个半径r和频率f,要从某一个点S走到另一个点T,然后再从T回到S。从S到T时,如果两个点表示的圆相交并且第一个点小于第二个点的频率的,那么能从第一个点到第二个点,从T到S时,第一个点的频率要大于第二个点的频率。除了S和T,每个点走后就会消失,问是否存在一种走法。相...
阅读全文
摘要:题目大概意思是给定一个矩阵A,每个元素都非负,主对角线上元素大于0,问是否存在常数k,使得A的k次幂的每个元素都大于0。由A的k次幂联想到离散数学中的可达性矩阵,即问是否存在常数k,使得任意两点之间都存在长度为k的路径,因为主对角线上严格大于0,也就是说有自环,所以只要该图是强联通的即可满足,因为若...
阅读全文
摘要:#include #include #define M 310#define inf 0x3f3f3f3fint n,nx,ny;int link[M],lx[M],ly[M],slack[M]; //lx,ly为顶标,nx,ny分别为x点集y点集的个数int visx[M],visy[M],...
阅读全文
摘要:将一个无向图删边得到一些子图,并使每个子图中存在哈密顿回路,并使所有哈密顿回路上边的权值最小。因为是哈密顿图,所以每个点入度和出度必须为1,将每个点拆成u,u',对于边,连接边,,KM即可。#include #include #define M 1100#define inf 1000000int ...
阅读全文
摘要:题目大意是有n个点,m条边,每条边有一个权值,问将所有点划分为圈的最小花费(每个点都在且仅在一个圈上)。因为每个顶点只出现一次,那么每个顶点只关联两个顶点入度顶点和出度顶点,所以构造二分图,将一个点u拆成u,u'。那么对于这个二分图如果存在着完美匹配的话,那么原图中一定存在若干个环,环中包含每个顶点...
阅读全文
摘要:在无向图上求s到t最短路径的条数且最短路径间不能有重边(即弱独立轨)#include #include #include #include using namespace std;#define maxn 2100#define INF 100000struct node{ int u,v,d...
阅读全文
摘要:线段树的区间加减数,区间查询#include #include using namespace std;#define LL __int64const int maxn = 100100;LL sum[4*maxn];LL add[4*maxn];void build(int l,int r,int...
阅读全文
摘要:以电影为x节点,天数为y节点,如果电影a需在w周之前完成,那么连接该电影节点到前w周能去的那几天,容量为1,源点s点连接每个电影节点,容量为该电影需要去的天数,每一天连接汇点 t ,容量为1,表示每天只能去一个,求最大流,如果最大流等于所有应去的天数,则输出yes,否则no。#include #in...
阅读全文
摘要:以高为数轴,维护每个区间的剩余最大值,用线段树二分做#include #define maxn 200100int Max[4*maxn];int h,w,n;int max(int a,int b){ if(a>b) return a; else return b;}void buil...
阅读全文
摘要:课程为x节点,时间为y节点,连边求最大匹配#include #include #define maxn 310int nx,ny;int g[maxn][maxn],ans,sx[maxn],sy[maxn];int cx[maxn],cy[maxn];int path(int u){ sx[...
阅读全文
摘要:线段树的区间修改#include #define maxn 100100 int set[4*maxn],sum[4*maxn];void push(int o,int m){ if(set[o]) { set[2*o]=set[2*o+1]=set[o]; sum[2*...
阅读全文

浙公网安备 33010602011771号