(Where I have marked in the word color ... gone directly copied here is not a standard)
Note the number of edges
initialization
Can not let go of each one of the conditions to consider how to achieve (emm ... because this sentence of 19 years in Shandong Province title race that water for a long time .. I think in the end edge dim ...)
2——sat :
https://www.cnblogs.com/WTSRUVF/p/9791282.html
At this
The other did not write the book to see more lrj blue
binary picture:
Ordinary match Dinic
Weighted bipartite graph KM
Before writing must determine what we ask, what to use.
Staining:
If divided into two teams
So that each team who know each other not know who built two sides then stained
So that each team of people do not know each other two people know the construction side and then coloring
FIG odd bipartite ring does not exist, it can be judged by staining odd ring
The picture is divided into the number of edges, and that the bipartite subgraphs > = m / 2 at a time to determine which stained even more and it is black, white, before this, it is classified as one of the few.
Maximum matching : the number of edges in the graph bipartite set the maximum matching;
Minimum Vertex Cover : with a minimum point, so that each edge and wherein the at least one point are associated; = maximum matching
Minimum edge covering: as few disjoint path covered simple directed acyclic graph all vertices (DAG) G; and (essentially required to have the longest path) = number of vertices - the largest match
Maximum independent set : N points in FIG selected points G, m, m make this point no edge points, the maximum value of m between any two. = Number of vertices - the largest match
Network flow:
See a black and white checkerboard model prior to staining calm down! ! !
With the cost of flow control to achieve the shortest times
Min assignment:
Full flow is the side of the edge to be deleted
Minimum cut is the minimum loss of value
For point designated to take, then it is the source || right side of the sink value of INF , represents a non-full flow, can not be deleted
For point linked, two-point edge weight is the weight of their relationship
The total weight increase and - Dinic () is the answer
No cutting to FIG minimum
Predefined state construction side
Categorized built side
According to the schedule, the time period built side
Cost flow split control traffic capacity cost difference
Bipartite graph multiple optimal matching Dinic
Multiple bipartite graph maximum matching cost maximum flow
Ring covering the minimum weight
Covering the minimum weight of the rings is a Hamiltonian circuit, cyclic, seeking the minimum and sides in the ring i.e. Node [i] .c == and the minimum value of KM or spfa 0
If the graph is undirected remember w [i] [j] = w [j] [i] = min (w [i] [j], tmp);
The minimum set of edges covered ( disjoint only at each point on a road )
Set smallest side is covered with a directed acyclic graph, find the n - max_flow, i.e. the number of acyclic graph with Dinic or Hungary hk
Maximum Weight closed subgraph
Directed graph, each point a little right, point right can be positive or negative. For any one directed edge i and J , select the point i have to select a point J , you need to choose some point such that the resulting maximum weight.
Profit left to spend on the right
Then all the profits - the maximum flow is the answer
Output options:
If the point to the left of i d [i]! = 0 then the selected i
If the right point j is d [j]! = 0 then the j is selected
The maximum density subgraph
s is 1 to each side edge of the right to build
Each edge to a value of INF side of u and v are built right
Each point of the value of t mid built right edges
Half mid
while(r - l > (1.0 / n / n))
{
double mid = (r + l) / (double) 2;
build(mid);
if(sum - Dinic() > eps) l = mid;
else r = mid;
}
Output Points
void f_dfs(int u)
{
for(int i = head[u]; i != -1; i = nex[i])
{
int v = Node[i].v;
if(!vis[v] && Node[i].c > eps)
{
view [v] = 1, f_dfs (V);
if(v - m >= 1 && v - m <= n) ans++;
}
}
}
Then output 1 ~ n points marked
s - t plan maximum flow
(Refer to the national team to this paper ... this figure is that of watching time so long ago forgot what the Baidu it ...)
Original even edge between st
Which is s * t * out for
Built between the edge of open space
Run spfa
FIG communication
1 , built in FIG 2 , condensing point [3 , Statistics degrees ]
Encounters asked whether u can to v Han and the like directly to a connected graph
Because any two points in a connected graph can reach each other
Then, even if each communication between both sides of FIG., That at most, is a directed acyclic graph
Bis point communication component
Path point does not overlap, any two sides are in the same simple loop ( Loop-free, non-edge weight ) , no internal cutting top
Connected component edges bis
Unique path side, each side are at least in a simple loop, all edges are not bridged inside
Condensing point strongly connected components can request directed No maximum loop
Binding Dinic minimum path cover ( disjoint ) beg for several
Ring is the most basic component of communication
In the tree can add the minimum number of edges in FIG communication becomes double FIG.
Conclusion: Adding the number of edges = (moderate tree of nodes 1 + 1) / 2
Shortest
Shortest amount of data between the two
LCA + spfa
. 1 , L CA of dfs processing point of all the non-tree edges save up ( in dfs v time if v has been traversed so u and v are non-point side of the tree )
2 , all non-tree edges traversing the point of spfa obtains the shortest of all points dis [i] [j] ( first dimension non-tree edge with a point in the array subscripts (reduce space) )
3 , for each query (set points of presence of the non-tree edges int a [maxn] in, and there ans a)
int x = lca(u, v);
LL res = dep[u] + dep[v] - 2 * dep[x];
for(int i = 1; i <= ans; i++)
{
Nothing = min (anything d [i] [u] + d [i] [v]);
}
printf(“%d\n”, res);
1, the most common short-circuit ( two-way reverse the construction side )
2, where the loop (positive loop negative ring) ( DFS token ring) (solution: spfa into the team after the determination IF (ANS ++ [EV]> n-) return. 1; )
3, hierarchical network (Solution: Because stratified, so the layer of abstraction to a point , then the current layer and layers each point connection, then the connection between the layers )
4, the differential constraint (SPFA run directly)
Selecting the maximum value: for inequality x [i] - x [j ] <= a [k], the establishment of a node j and j i -> i directed edge, for the most short-circuit
Minimization: For the inequality x [i] - x [j ]> = a [k], the establishment of a node j and j i -> i directed edge, find the longest path
FIG if none, then when spfa beginning, all nodes into a queue , the following code
Whether seeking the maximum or minimum requirements are written
for(int i=1; i<=n; i++)
{
Q.push(i);
d[i] = 0;
view [i] = 1;
}
Note that the lower bound of other passive Shortest have also written
Note that between the implied conditions, are generally two adjacent points
i sum i + 1
If each point has a range of the set point of a source n + 1
To ZOJ 4028 , for example
l <= a[i] <= r
则 l <= a[i] - a[n - 1] <= r
If there is a negative ring no solution is
required not shortest
dist [] (first determine whether there is a negative ring, and then determines whether the shortest i.e. determined whether any solution and then outputs a positive solution not updated
if(spfa())
printf ( "no solution \ n");
else if(d[n] == INF)
printf ( "any solution \ n");
else
printf("%d\n", d[n]);
Do differential inequality constraints must find a relationship, in general, two unknown variables, like hdu1384 seeking this interval is coincident with the elements, then we can be transformed into sum (a) represents a range of 0 to coincide with the answer set element
Then the sum (b) - sum (a - 1)> = w or <= w SUM it is not (a) and SUM (b) respectively, a and b would be sufficient
Like hdu 3666 must be the product of inequality have thought about that log log (a) and log (b), respectively, can be represented by rows and columns
6, transitive closure (transmitting a relation with the Floyd)
7, the maximum value is minimized
if(d[e.v] > max(d[x],e.d))
{
d[e.v] = max(d[x],e.d);
if (you [en])
{
Q.push(e.v);
vis [ev] = 1;
}
}
The minimum value maximization
if(d[e.v] < min(d[x],e.d))
{
d [home] = min (d [x], ed);
if (you [en])
{
Q.push(e.v);
vis [ev] = 1;
}
}
8 , layered shortest path ( Dijkstra )
Minimum spanning tree
step:
First with Node deposit side
By weight in ascending order (if the output lexicographical ordering equal, if the weight in the u rows, u is also equal press v row)
Select each edge disjoint-set
The same time res + = Node [i] .w ;
Asked many times to minimize the maximum value of the shortest path between two points is a minimum spanning tree bottleneck