. For example, this problem can be seen at a glance is the maximum flow of two points to determine whether it is feasible.(Bob is sure to pile up all the expenses on the side where the traffic is the biggest in order to make the most profit)So confidently knocked two points on the answer up, confident to submitHowever, WA dropped.WTF why is the flow a real number?Think carefully, although the title is not explicitly, but it is really a real number.Kneeling in the language.1 /*by Silvern*/2#inclu
Thinking of solving problemsIt should be more obvious that this is a network flow, will be $s$ with the room, the room with the people, the people and the food side, food and meeting point edge, edge of the flow of 1. But this is wrong, because it is possible for a person to run past 2 of the traffic, so the person will be removed to limit the flow.#include #include#include#include#include#includeusing namespacestd;Const intMAXN =505;Const intMAXM =50005;Const intINF =0x3f3f3f3f; inlineintRd ()
root node of both chains in the answer is not 1,So this caterpillar also includes the Father node of the root nodeIf the root node happens to be 1, there is no so-called "Father Node"So we have to judge.Set Select[i]=true to indicate that the root node is IThe final judgment can be#include #include#include#defineN 300005using namespacestd;intn,m;structedge{intU,V,NXT;} E[n*2];intCnt,first[n];voidAdd_edge (intXinty) {e[++cnt].u=x; E[CNT].V=y; E[CNT].
Learned the Dijkstra.Like greed.It's kind of like Freud.On the code.This specifies that the starting node is 1.1#include 2#include 3#include string>4#include 5 6 using namespacestd;7 #defineMAXN 100018 #defineMAXM 1000019 Ten //N-point m-side One A structedge{ - intv; - intW; the intNXT; - }E[MAXM]; - intHEAD[MAXN]; - intCNT; + - voidAddedge (intXintYintz) { +e[++cnt].v=y; AE[cnt].w=z;//Benquan ate[cnt].nxt=Head[x]; -head[x]=CNT; - } - i
can get some benefits, each employee needs to pay some salary, each project corresponding to several employees, each employee can participate in multiple projects, to find the maximum benefit.Analysis:This problem can be converted to the maximum right of the closed sub-graph, the project as a positive value of the point, the staff as the weight of the negative points, each project corresponding to a number of employees that is, if you want to choose this project must choose these employees, tha
problem, if you can finish the painting of the direct output of the scheme, if you can not finish painting, then must be in the middle of an odd number of nodes encountered in the ring. Therefore, in order to better record the color of the relationship, here should use DFS, and in the face of contradictions, back to the point where the contradiction is painted, got an odd ring.In general, there is no odd ring, then the coloring must be successful, there are odd rings, the output of odd rings, t
..k:for Each distance query, output on a single line an integer giving the appropriate distance.Sample Input7 6 E6 3 9 E3 5 7 S4 1 3 N2 4 W4 7 2 S31 61 42 6Sample Output13336HintFarms 2 and 6 are 20+3+13=36 apart.Test Instructions Summary:Input:The first line is the input node N and the number of sides M.Next M Line input edge information: Start U end point v distance w direction sNumber of input Queries KThe next K line enters the query value: Start u, end point V;Problem Solving Ideas:A direct
, indicating the shortest distance to be drawn for that inquiry.Sample inputSample Input31 0 12 0 131 02 01 2Sample outputSample Output112Data range and TipsData Size Hint1Test Instructions Summary:One thing to note is that the information given to the edge is given to the child node and then to the Father node.Problem Solving Ideas:DFS preprocessing the distance from each node to the root node of the tree (if a double-sided edge is to be weighed)Tarjan find the nearest public ancestor, the old
P1351 Joint Weight ValueWant to brush the water problem also handed over 3 times ..... Embarrassing(1. I didn't expect two points to be a son's condition. 2. Everywhere (FOG))First, DFS handles the father $fa[x]$ again.Blue and then again DFS, get out of the mess.#include #include#include#defineRe Registerusing namespacestd;Const intp=10007;intMaxinta,intAMP;B) {returnA>b?a:b;}#defineN 200002intN,fa[n],val[n],f1[n],f2[n];intcnt,hd[n],nxt[n1],ed[n],poi
This is Bzoj ah ...DFS can pass a parameter without exploding.But why 0msWA?Yes, not yes ...#include #include#include#include#defineMAXV 500500#defineMaxe 1000500using namespacestd;structedge{intV,NXT;} E[maxe];Chartype[5];intN,c[maxv],x,y,nume=0, g[maxv],m;intFath[maxv],size[maxv],dis[maxv],top[maxv],w[maxv],son[maxv],cnt=0, FW[MAXV];intls[maxv2],rs[maxv2],val[maxv2],tot=0, Root;voidAddedge (intUintv) {e[++nume].v=v; E[NUME].
, AXB in a=b when the maximum value, a and B difference between the more , the smaller the AXB, so we can make a smaller, so we can choose a degree or out of 0 of the component as X, select the least point of the block as X, then ans is the largest.Sentiment: Feeling this problem is very good to combine the idea of graph theory and mathematics divide together.#include #include#include#includeusing namespacestd;#defineMAXN 100010intDFN[MAXN],LOW[MAXN],ID[MAXN],SUM[MAXN],inch[MAXN], out[MAXN];intH
, each point has the right value, the request from (to n,n), the weight of the distance is passed through the lattice of weights, but once through the lattice, the weight of the lattice has become 0, asked to go K times, so that the first k times the sum of the weight of the largest ...Analysis:Maximum cost maximum flowWe have to satisfy the weights of each lattice can only be taken once, so the split, from the point of entry to the point of a capacity of 1 for the-val of the side, but can go th
$ scenarios. If the problem is not solved, the output "$No \;\; solution!$ " Sample Input 3 153 3 42 1 21 31 31 31 33 1 2 32 2 32 1 31 21 22 1 22 1 32 1 21 13 1 2 3 Sample Output 1:1 6 82:7 9 103:2 3 4 5 HINT $2\;\leq\;k\;\leq\;20,k\;\leq\;n\;\leq\;1000$ Solution The category $i$ is $x_i$, the title $i$ is $y_i$. From $s$ to $x_i$, a forward edge with a capacity of $a_i$ is connected, From $x_i$ to $y_j$, a forward edge with a capacity of $1$ (title $j\in$ category $i$) is connected to the Fr
. Indicates that both driver A and copilot B can fly on the same machine. Note: The pilot's number is before the driver's number is less than the pilot's number. Output format output file has one lineThe first line, 1 integers, indicates the maximum number of aircraft to take off. Input Output Sample input file name: Flyer.in10 51 72 62 103 74 85 9Output file name: Flyer.out4Maximum flow of network streamsThe title description is obvious. Source point connected to the pilot, is the pilot with th
Output3Output Explanation:One scenario is:Cow 1: Don't eatCow 2: Food #2, beverage #2Cow 3: Food #1, beverage #1Cow 4: Food #3, beverage #3There is no better solution with the pigeon cage theorem (altogether there are only 3 total foods and drinks). Of course, the other data will be more difficult.HINT SourceGoldMaximum flow problem.The super-starting point to the food, food to the cow, the cows into the point and out point, into the point of food, point to drink, drink to the edge of the meeti
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.