二分图最小不相交路径覆盖 #include<bits/stdc++.h> using namespace std; ; ; ; ], nxt[MAXM << ], f[MAXM << ], ed = , S, T; inline void addedge(int u, int v, int cap) { to[++ed] = v; nxt[ed] = Head[u]; Head[u] = ed; f[ed] = cap; to[++ed] = u; nxt[ed] =…
Consider a town where all the streets are one-way and each street leads from one intersection to another. It is also known that starting from an intersection and walking through town's streets you can never reach the same intersection i.e. the town's…
传送门 枚举球的个数 num 如果 i < j && (i + j) 是完全平方数,那么 i -> j' 连一条边 再加一个超级源点 s,s -> i 再加一个超级汇点 t,i' -> t 那么当前可以放的柱子的最小数量就是最小不相交路径数 如果当前的最小不相交路径数 > num,break 求最大流的时候别忘了记录方案 ——代码 #include <cmath> #include <queue> #include <cstdio…
传送门:http://poj.org/problem?id=1422 Air Raid Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9303   Accepted: 5570 Description Consider a town where all the streets are one-way and each street leads from one intersection to another. It is…
Air Raid Consider a town where all the streets are one-way and each street leads from one intersection to another. It is also known that starting from an intersection and walking through town's streets you can never reach the same intersection i.e. t…
输入一个n×m网格图,每个结点的值为0-9,可以从任意点出发不超过k次,走完每个点且仅访问每个结点一次,问最终的能量最大值.不可全部走完的情况输出-1. 初始能量为0. 而结点(x,y)可以跳跃到结点(x,y+dy)或(x+dx,y).消耗能量为跳跃前后结点的曼哈顿距离 - 1 .若跳跃前后的结点的值相等,能量加上那个值. 具体建图可以参考这里http://blog.sina.com.cn/s/blog_6bddecdc0102uy9g.html 最小K路径覆盖其实在之前是见过的打过的,不过这次…
多校联赛第一场(hdu4862) Jump Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 644    Accepted Submission(s): 275 Problem Description There are n*m grids, each grid contains a number, ranging from 0-9.…
Destroying The Graph Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 8198   Accepted: 2635   Special Judge Description Alice and Bob play the following game. First, Alice draws some directed graph with N vertices and M arcs. After that B…
最小点权覆盖就是,对于有点权的有向图,选出权值和最少的点的集合覆盖所有的边. 解二分图最小点权覆盖集可以用最小割: vs-X-Y-vt这样连边,vs和X部点的连边容量为X部点的权值,Y部和vt连边容量为Y部点的权值,X和Y是原二分图中的边容量为INF. 这一题建二分图是这样的:把原图中的点拆成两个点分别作二分图的X部和Y部,一个入点u+一个出点u-,权值就是题目给的那两个:原图中每条有向弧<u,v>变成二分图的边(u-,v+). 然后就是建立容量网络,利用最小割求出这个二分图的最小点权覆盖集.…
题意 有一个图, 两种操作,一种是删除某点的所有出边,一种是删除某点的所有入边,各个点的不同操作分别有一个花费,现在我们想把这个图的边都删除掉,需要的最小花费是多少. 思路 很明显的二分图最小点权覆盖集.WA在输出最小割方案上. [输出最小割方案]从源点S做一次DFS遍历,标记所有访问到的点,这些点就是S点集.然后对于每一条满流边,如果其两端点一个在S点集一个不在则该边就是此方案下的最小割边. 代码 [cpp] #include <iostream> #include <cstdio&g…