Recently learned two of the maximum match, BFS template is still dead or alive to fight out? I might have learned the fake BFS.So I used the DFS template.The algorithm for finding the maximal matching of binary graphs is the Hungarian algorithmThe main procedure of the Hungarian algorithm is to find the augmented pathLooking for a way to shine is the process of starting from an unpaired point, after an unmatched edge, matching edge, mismatched edge, matching edge, mismatched edge 、... Finally, t
'; + if(k=='-') x=0-X;returnx; A } at - structedge{ - intto,nxt; -}e[maxn*2];//chain-forward star achievement - - voidinit () { inmemset (head,-1,sizeofhead); -tot=0; toId=0; +ans=0; - } the * voidAdd_edge (intUintv) { $e[tot].to=v;Panax Notoginsenge[tot].nxt=Head[u]; -head[u]=tot++; the } + A voidDfsintUintFaintDEP) { theVer[++id]=u;//number of nodes visited by the first I +DEPTH[ID]=DEP;
pragma comment (linker, "/stack:1024000000,1024000000") include
Include
Include
Include
Includeinclude
Define RE registerdefine inf 400000000define maxn 10005define MAXM 200001
using namespace Std;int n,s,q,dis[2000011],t,l,cur[200051],m,tot,cnt;int id[101][101],a[101][101],b[101][101],a1[101][101],b1[101][101],a2[101][101],b2[101][101];struct PO{int nxt,to,w;}EDGE[MAXM];int head[maxn],dep[maxn],num=-1;inl
P1345 [USACO5.4] cow's telecom telecowmunicationActually, we're asking for some cuts.We can split a point into two points, with only one and a 1-capacity edge.Then the minimum cut is asked. Minimum cut equals maximum flow 233Dinci is OK .#include #include #include #include #include using namespaceStdstructnode{intPointintNxtintWeight;}; Node line[6000];inthead[6000],tail=-1;voidAddintXintYintz) {line[++tail].point=y; Line[tail].weight=z; LINE[TAIL].NXT
enter which stack. Can be into the stack 1 of all into the stack 1.Then the simulation implementation, each time to determine whether you can pop off the top of the stack elements, and then according to the previous preprocessing scheme put in the number.#include using namespacestd;Const intn=1010;intA[n],la[n],co[n];intN;intHead[n];intCnt=1;BOOLflag=0;intsta[3][n];//record stack 1, stack 2inttop[3];//Record Stack TopintGo[n];//The number in this position to go to which stackinthas;//What 's th
statistic.And then this question to use unsigned long long then also can't open, will Mle1#include 2#include 3#include 4#include 5#include 6 using namespacestd;7 Const intn=100100;8 intCnt,head[n];9 intSize[n],id[n],tot;Ten intnum[ -],block[n],f[ -][n]; OneUnsignedLong Longsum[ -],a[n],tr[n],ans,v[n]; A intn,m,r[ -],l[ -],block,root; - structedge{ - intto,nxt; the}e[n*2]; - voidAddintUintv) { -cnt++; -e[cnt].
;//If you do not specify GreaterintN//Number of buttonsintans[maxn]={0};//Record Storage Results//Initialize input graphvoidinit () {scanf ("%d",N); G=New int*[n+5]; for(inti =1; I //The edge of each node { intm =0; scanf ("%d", m);//The number of edges that record this pointG[i] =New int[m+Ten]; g[i][0] =m; for(intj =1; J 0]; ++j) {scanf ("%d",G[i][j]); inch[g[i][j]]++;//the entry of the J-Point plus one } }} //returns whether the topology can be sortedBOOLTopologicals
componentThe non-direction graphSide Double Unicom diagram: If in an undirected graph, any two points have at least two edges not repeating the path, it is said that the graph is the edge of the two-connected .Side Dual-Link component: The maximal sub-graph of the side-double connectivity is called the edge-connected component .The principle is similar to the method of strong Unicom component.1 voidTarjan (intUintFA) {2Dfn[u] = Low[u] = + +tn;3St[++top] =u;4Vis[u] =true;5 for(intI=head[u];
A * algorithm, also called Heuristic Search, is to design an estimate function, and then in the process of searching for an orderly search, we set to the current state of the cost of f (x), to the target state of the estimated cost of H (x), then we sort by H (x) +f (x), the beginning to the current distance f (x ), the current to the end of the shortest circuit is g (x), and then a violent search can be. --by Vane#include using namespacestd;Const intn= -;Const intm=10050;Const intinf=1e9;intn,m
Blog:www.wjyyy.top
ac automata is a convenient multi-pattern string matching algorithm for cancer . Based on the dictionary tree, a similar kmp thinking is used.
ac automata unlike KMP, AC automata can match multiple pattern strings at the same time, and the complexity does not reach too high. If the string is matched multiple times with KMP, the complexity is \ (O (k (n+m)) \).
We know that it is most convenient to use a dictionary tree to match a string header to match the other strings ex
Bzoj_1179_[apio2009]atm_tarjan+spfaTest instructions: http://www.lydsy.com/JudgeOnline/problem.php?id=1179Analysis:Obviously there is no way to direct the longest road, then shrink the point to run.The bar connects to meeting point.Code:1#include 2#include string.h>3#include 4 using namespacestd;5 #defineN 5000506 inthead[n],to[n1],nxt[n1],val[n],can[n],cancan[n];7 intn,m,bel[n],dfn[n],low[n],st[n],top,scc,tot,cnt,s,t;8 intIns[n],sum[n],x[n],y[n],q[n]
integer) as stringIf W> = 0 then mimeencode = mid $ (base64, W + 1, 1) else mimeencode = ""End Function
Private function mimedecode (A as string) as integerIf Len (A) = 0 then mimedecode =-1: Exit FunctionMimedecode = instr (base64, a)-1End Function
Public Function encode (byval indium as string, byval e as long, byval N as long) as stringDim s as stringS = ""M = IndiumIf M = "" Then exit functionS = mult (clng (ASC (mid (M, 1, 1), E, n)For I = 2 to Len (m)S = S "+" mult (clng (ASC (mid (M, I
. 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 ()
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service