multiple boys, the final maximum flow will be reduced.#include #include#include#include#includeusing namespacestd;Const intdian=305;Const intbian=40005;Const intinf=0x3f3f3f3f;intN,k,tot;ints,t;intH[dian],nxt[bian],ver[bian],val[bian],ch[dian];Charmap[ -][ -];voidAddintCanintBbintcc) {Tot++;ver[tot]=bb;val[tot]=cc;nxt[tot]=h[aa];h[aa]=tot; Tot++;ver[tot]=aa;val[tot]=0;
Title Link: Hdu_5314_happy KingTest instructionsGive a tree of n nodes, point the right value;Find the difference between the maximum and minimum values for a pair (x, y) that satisfies x!=y and x to Y paths ExercisesOr the point of the tree, in the statistical answer to the root of the first order of the minimum value, and then use the maximum value minus D to find how many meet the answer.1#include 2 #defineF (I,A,B) for (int i=a;i3 using namespacestd;4typedef pairint,int>P;5typedefLong Longll
longest chain with the point right to the graph.Number of programmesIt is easy to find the longest chain in a DAG, either with a memory search or a topological sort. The number of solutions, that is, similar to the DP method, using $g[i]$ to express the longest chain of $i$ as the end of the program number, transfer is also very convenient.Yes, in order to count the number of scenarios, the connecting edges between the blocks need to be weighed.From the Huang blog to learn a very clever way to
Test Instructions: give a direction graph, the beginning S to the end of the T-K short, the absence of the output-1#include #includestring.h>#include#includeusing namespacestd;Const intINF =0x3f3f3f3f;Const intMAXN =1024x768;Const intMAXM =100008;structedge{intV, NXT, W;};structnode{intPos, cost, F; BOOL operatorConstNODE RHS)Const{//pay attention to symbols when overloaded if( This->f = = RHS. Freturn This->cost >RHS. cost; return T
Test instructions: Give us a diagram, ask us to at least divide this graph into parts, so that any two points within each part can be guaranteed at least one-way connectivity.Idea: Use the Tarjan algorithm to find strong connected components and then to shrink points, to form a new map, easy to know the new map of each point inside the internal points can be guaranteed bidirectional connectivity, and the new map points are one-way non-ring, this time the topic requirements of the Division of the
Title: http://www.lydsy.com/JudgeOnline/problem.php?id=2160After the construction of the palindrome tree, from the back to sweep again, so that cnt[fail[i]]+=cnt[i], you can get the number of occurrences of each string. Then for a palindrome tree in a node, its length is len[i], the number of occurrences of cnt[i], then we take out the first K-length of the odd string multiplication on it. Fast power.#include #include#include#include#defineRep (i,l,r) for (int i=l;i#defineDown (i,l,r) for (int i
Title: http://acm.hdu.edu.cn/showproblem.php?pid=5421Because to be in front of the character, so maintain a prefix chain and suffix chain, on the same palindrome tree, if there is a longest palindrome suffix (or prefix) length of the total, then let the prefix (or suffix) of the last also assigned to the current node.#include #include#include#include#defineRep (i,l,r) for (int i=l;i#defineDown (i,l,r) for (int i=l;i>=r;i--)#defineCLR (x, y) memset (x,y,sizeof (×))#definell Long Long#defineMAXN 2
Who would set the INF to 0x3f like me?GH Tree.#include #include#include#include#include#defineMAXV 250#defineMaxe 50050#defineINF 0x7fffffffusing namespacestd;structedge{intV,F,NXT;} E[maxe];intt,a,b,c,qq;intN,M,MAP[MAXV][MAXV],F[MAXV][MAXV],S,T,NUME,G[MAXV];intRegis[maxv*maxv],cnt=0;intDis[maxv],fath[maxv],rrr=0;BOOLVis[maxv];queueint>Q;voidReset () { for(intI=1; i) for(intj=1; j) {Map[i][j]=0; F[I][J]=inf; }}voidAddedge (intUintVintW) {e[++n
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5303Test instructions: There are n person M edge, each side has a u,v, the age of the U is greater than or equal to V, now to divide the n person into x groups, the age of the group can not be directly or indirectly compared, ask at least how many groups can be divided.Idea: At first did not see test instructions, the direct topological sort did. Later listen to brother said there will be a ring, age is equal to, if there is a ring repre
n boxes in a circle, the first box I have an AI ball, each time you can move a ball from a box into one of the two adjacent boxes. Ask how many times to move so that the number of balls in each box does not exceed 1.σaiMinimum cost maximum flow.Each box as a point.If the ai>1 is connected to this point from the source point to a capacity of AI, the cost is 0 side.If the ai=0 is from this point to the meeting point a capacity of 1, the cost of 0 side.Each box is connected to the adjacent two boxe
corresponding problem (AI,BI) The point of the remaining number of coverage minus one. It is noted that the interval of the subject is open, so the two-interval connection does not affect the result.1#include 2#include 3#include 4#include 5#include 6 using namespacestd;7 Const intdian=405;8 Const intbian=1505;9 Const intinf=0x3f3f3f3f;Ten intZkh[dian],ykh[dian],khqz[dian]; One intZl[dian],yl[dian]; A intH[dian],nxt[bian],ver[bian],val[bian],cos[bian]
http://acm.hdu.edu.cn/showproblem.php?pid=4292Test instructions: It's almost like a cow, but there are a variety of foods.Idea: Because of the variety of food, so the source and meeting point capacity to be changed. and Dinic and Tle, with ISAP.#include #include#include#include#includestring>#include#include#include#include#includeSet>using namespacestd;#defineINF 0x3f3f3f3f#defineN 910typedefLong LongLl;typedefLong LongLL;structEdge {intV, Cap, NXT;
Ah good to bother with this problem ....Basic ideas are available online.One thing to note is that if the source of the army is not matched at the time of the match, then the source is matched first. (for no cost).But the data good water ....#include #include#include#include#defineMAXV 50050#defineMaxe 100500using namespacestd;intN,x,y,z,g[maxv],nume=0, m,c[maxv],anc[maxv][ -],dis[maxv][ -],l=1, r=0, disr[maxv],kr=0, FATH[MAXV];inttop=0, cnt=0;BOOLVIS[MAXV],RET[MAXV];structedge{intV,W,
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.