Test instructions: For a forward graph, ask the maximum number of points in the group, requiring at least one path between all the point pairs in the point set (U to V or V to u or two bars).First of all, for each strong connected component, where all the points must be able to reach each other, so the first indentation, and then for the dag,dp[i after the indentation of the maximum number of points that can be reached from the I-strong connected component, then at the point of indentation, we n
This is a basic dichotomy, test instructions better understand, give n individuals, of whom m pairs of people who do not know, first let us judge whether we can divide the n pairs into two parts, which is used to determine the dichotomy of the method, the two-figure is no caused by parity number of edges constitute a ring diagram, here with the BFS staining method can be judged, Next let us find in two parts of the maximum logarithm, this is the binary graph of the maximum matching problem, wher
Dinic to solve the problem of network flow template. Queue with STL on Tle ...1 /*3061*/2#include 3#include string>4#include 5#include 6#include Set>7#include 8#include 9#include Ten#include One#include A#include -#include -#include the#include -#include -#include -#include +#include -#include + using namespacestd; A //#pragma COMMENT (linker, "/stack:102400000,1024000") at - #defineSTI set - #defineStpii Set - #defineMpii map - #defineVI vector - #definePII pair in #defineVpii vecto
ChannelTest instructions: Give a 1-letter tree asking if a string appears in the treeIdea: Direct Search pruning, people point division? Wrote a few hair is t. Somebody's going to teach me?Code:#include #include#includeusing namespacestd;structEdge {intV, NXT; Edge () {} Edge (int_v,int_n) {v= _v, NXT =_n; }};Const intMax_n =10007;intHead[max_n], N, Len, ecnt, Tim;CharA[max_n], b[max_n];intDis[max_n], F[max
maximum number of matches after the break.1#include 2#include string.h>3#include 4#include 5 using namespacestd;6 7 Const intmaxn=10005;8 Const intmaxm=2e5+5;9 Ten inthead[2][maxn],point[2][maxm],nxt[2][maxm],size[2]; One intn,t,scccnt; A intSTX[MAXN],LOW[MAXN],SCC[MAXN]; - intVIS[MAXN],MATCH[MAXN]; -stackint>S; the - voidinit () { -memset (head,-1,sizeof(head)); -size[0]=size[1]=0; + } - + voidAddintAintBintC=0){ Apoint[c][size[c]]=b; atnxt[c][siz
Topic Link:https://uva.onlinejudge.org/index.php?option=com_onlinejudgeitemid=8page=show_problem problem=2473ExercisesFirst we can get the constraints of shape such as Xi-xj If there is a negative circle, the original difference system has no solution.Simple proof:We might as well set this ring to X1,X2...XN.That is, there are inequalities x1 All add up to 0 Therefore, the solution must satisfy Sigma (Y) >= 0, if there is a negative circle, there is definitely no solution.So how to judge the inf
Test instructions: Like poj1680, there are different ways to exchange money, you can complete a particular two currencies, and there is exchange rate, but the problem is one-way side, and then ask whether it can increase the wealthAs with poj1680, the SPFA of the value-added rings can be1#include 2#include 3#include string>4#include 5#include 6#include 7#include 8 using namespacestd;9 Ten inthead[ *],nxt[ +],point[ +],size; One Doubleval[ +],dist[ *];
At first glance a template question, a careful look or template problem, but three pits. 1, not a connected graph, put 0. 2 Guards are 0 and 1 are placed. 3 Note the heavy edges.#include #include#include#include#include#include#includeusing namespacestd;#defineMAXN 1005intHead[maxn],dfn[maxn],low[maxn],guard[maxn][maxn],tot,n;intvis[maxn],all,index,bri[maxn*MAXN];structedge{intTo,nxt,g;} EDGE[MAXN*maxn*2];queueint>que;voidBFsintu) {Vis[u]=1; Que.pu
DescriptionN Cattle (2Input* First line: Two integers separated by a space: N and Q* Line two to Nth: line i+1 has two integers separated by spaces: Ai,bi,li* Line n+1 to n+q: Each line has two spaces separated by an integer: P1,p2, which indicates the number of two cows.Output* Line 1th to line Q: Output one number per line, indicating the distance between the two cows.Sample Input4 22 1 24 3 21 4 31 23 2Sample Output27HINTSourceQualifying TournamentSolutionNaked LCA, people who can't read the
DescriptionIn order to make their sons brave, Jiajia and wind take them to a big cave. The cave has n rooms, and one-way corridors connecting some rooms. Each time, wind choose the rooms x and Y, and ask one of the their little sons go from one to the other. The son can either go from X-to-y, or from Y to X. Wind promised that her tasks is all possible, but she actually doesn ' t Know how to decide if a task is possible. To make hers life easier, Jiajia decided to choose a cave in which every pa
point of the graph, must connect 3 lines, will be any three points 22 connected, the case number is any combination of three points.1#include 2#include string.h>3#include 4 using namespacestd;5typedefLong Longll;6 7 intc[100005];8 intn,m,num[2];9 inthead[100005],nxt[200005],point[200005],size=0;Ten BOOLf=0; One A voidAddintAintb) { -point[size]=b; -nxt[size]=Head[a]; thehead[a]=size++; -point[size]=A; -
The general idea is to do one step at a time from the end of the BFS to get a level diagram, and then start from the beginning to the smaller layer run, run when the dictionary order is the smallest, because there may be a number of points to meet the conditions, so the layer satisfies the conditions of the point to save, in the next layer of running. After running a layer, you will get the lowest color of this layer.Introspection: This problem is due to the existence of self-loops and heavy edg
position that each joins has not yet queried, with a total of M. Similarly, define a three-dimensional DP array, dp[i][j][k]: = The total number of laying schemes when the state is k when laying position (I, J). Let's deduce the state transition equation for this DP. For the current position (I, J), set the state of the enumeration to used, check that the position (I, j) is required to place the bricks simply by looking at used >> J 1 is 1, if 1 is no longer required and must have (I+1, j) for
Perfect for a A * problem.More than the usual maze problem plus a message K indicates the number of obstacles currently passing through.#include #include#includeusing namespacestd;Const intMAX = +;intm,n,k;intC[max][max][max];intG[max][max];inttarx,tary;structnode{intg,h; intx, y;//The greater the distance from the end of the subject x+y the closer intK; BOOL operatorConstnode RHS)Const{ if(g + H > rhs.g + rhs.h)return true; if(g + H return false; if(g > RHS.G)return true; if(G return fal
Topic Link: hdu_5788_level upTest instructionsThere is a tree, n nodes, each node has a capability value a[i],mid[i],mid The median of the sub-tree of the I node (including itself), and now lets you change one of the nodes to a value of 1e5, asking all of the mid's and the maximum number of questions.ExercisesWe can know that if you change one of the a[i], if a[i] is smaller than the mid of his father's node, then the median of his father's time will be shifted back oneFor example, 1 2 3 4 5, th
substrings containing at least one b:b, BB, BBB. Authorfzu Source2016 multi-university Training Contest 4Test instructions: Enter the character x and a string to find the number of different substrings containing the character x;Idea: Suffix array sum=length-(sa[i]+height[i]) [i from 1~length] sum is the number of substrings, slightly modified, with nxt[i] to the right of I distance I the nearest character x coordinates, thenSum=length-max (
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.