邻接矩阵:#include #include #include using namespace std;#define min(a,b) a s;void dfs(int u){ Edge t,tt; dfn[u]=low[u]=++tmpdfn,visit[u]=1; for(i...
分类:
其他好文 时间:
2014-08-03 15:07:56
阅读次数:
256
题目来源:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1256 一个完全单向的有向图,最少更改多少条边能够从1到N。把原有的边的权值设为0,换方向的边的权值设为1。简历邻接表。add_edge(u,v,0);add_edge(v,u,0);采用....
分类:
其他好文 时间:
2014-08-01 22:57:32
阅读次数:
204
题解:对于输入的边,我们首先按照速度从大到小排序,然后对于每一次询问,st end 两个城市,我们暴力枚举,
for(int i = 0; i
上马:
//187MS 300K
#include
#include
using namespace std;
#define MAX 205
#define INF 1<<30
int N,M,Q;
struct Edge
{
...
分类:
其他好文 时间:
2014-08-01 10:53:31
阅读次数:
204
枚举所有相邻城市,作为起点,多次spfa,然后每次在想去的城市中找出spfa后的距离起点最短的花费时间
#include
#include
#include
using namespace std;
#define MAX 1005
#define INF 1<<30
int T,S,D;
struct Edge{
int to,time,next;
}edge[MAX*2...
分类:
其他好文 时间:
2014-07-30 12:19:03
阅读次数:
215
费用流即最小费用最大流先贴上粉书上的模板:struct Edge{ int from,to,cap,flow,cost; Edge(int u,int v,int c,int f,int w): from(u),to(v),cap(c),flow(f),co...
分类:
其他好文 时间:
2014-07-30 00:27:02
阅读次数:
289
解法:对u->v的边 add_edge(u,v,0)增加一条u->v反向边 add_edge(v,u,1)求一遍1->n的最短路#include #include #include using namespace std;#define M 20010 //用了几次 10010 R...
分类:
其他好文 时间:
2014-07-29 16:57:32
阅读次数:
220
EK算法:
int fir[maxn];
int u[maxm],v[maxm],cap[maxm],flow[maxm],nex[maxm];
int e_max;
int p[maxn],q[maxn],d[maxn];
void add_edge(int _u,int _v,int _w)
{
int e;
e=e_max++;
u[e]=_u;v[e]=_v;c...
分类:
其他好文 时间:
2014-07-29 14:20:08
阅读次数:
232
第一道Kruskal算法题#include #include #include using namespace std;#define max 505int f[max],maxw;struct edge{ int st,en,w;}ed[max*max/2];int find(int k){ if...
分类:
其他好文 时间:
2014-07-28 15:39:43
阅读次数:
181
点击打开链接
二分图匹配,hopcroft-karp
#include
#include
#include
#include
using namespace std;
const int MAXN = 5010;
const int MAXM = 50010;
struct Edge{
int to, next;
}edge[ MAXM ];
int head[ MAXN ], to...
分类:
其他好文 时间:
2014-07-27 11:45:03
阅读次数:
225
内部也是相交#include #include #include #include using namespace std;struct point{ int x,y;};struct edge{ point start,end;}line[4],the;void swaped(int &x,int...
分类:
其他好文 时间:
2014-07-26 14:31:00
阅读次数:
272