topic links >Main topic:There is a string a, rewrite a A, will get a new string aaaaaaaa ...., now cut this string from a portion to get a string B, for example a string a= "ABCDEFG". Copy a few times to get ABCDEFGABCDEFGABCDEFGABCDEFG ...., now cut the middle red part, get the string B, now just give the string B, and find out the length of the string A.Problem Solving Analysis:It is not difficult to find that the definition of a is actually the shortest circular section in the string definiti
Test instructions: A weighted graph, the sum of the two path weights of the beginning to the end, and the two paths have no common points (except the starting point, the end point);Analysis: Split-point method, the U and U ', u-u ' capacity of 1, the cost of 0, so that each point can be used only once, the starting point s-s ' capacity of 2, the end T-t ' capacity of 2 to ensure that the maximum flow will find two path, if the input u-v, the right is C, then increase the edge U '-V, the capacity
From the end of the thrust, D[u] represents the remainder of the goods entering u, then the number of goods before entering U is set to y,d[u] = x, then Y-x=ceil (y/20.0) = (y-1)/20+1= (y+19)/20.(y-x) *20+r=y+19,0≤r≤19, that is 19*y=20*x+r, according to test instructions y should be as small as possible, the part of x is not variable, so Y=x+ceil (x/19.0).Then find a path with the smallest dictionary order from the starting point, because each letter is unique, so do not need to BFS, each time y
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
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.