This is the minimum cut, but I think for a long time ....Consider all sheep connected to the source point, the wolf connected to the meeting point, adjacent points on both sides of the minimum cut (maximum flow) can be.Correctness? Considering something like a dichotomy, we just need to set the wolf together and waist the sheep.#include #include #include #include #define Maxe 100005#define MAXV 10011#define INF 1234567#define S 0#define T 10010using namespace Std;int n,m,map[105][105],dx[]={0,0,
The main problem: give the M disease gene fragment (mAnalysis: The subject needs to build an AC automaton for the gene fragments of M disease, and each node in the automaton represents a state. The leaf nodes in the AC automata represent viruses, so they are illegal. At the same time, if a node to the root of the string suffix is a virus, then the node is also an illegal state. Eliminate all illegal state, then the rest of the nodes are in the legal state. The node's
. Input the first line ofinput(Input)Containsintegers(integer)M and N, 1 The next line contains M Integeres, for each pig-house initial number of pigs. The number of pigs in pig-house are greater or equal to 0 and less or equal to 1000.The next N lines contains records about the customers in the following form (record on the i-th customer is written in The (i+2)-th line):A K1 K2 ... Ka B It means that this customer have key to the pig-houses marked with the numbers K1, K2, ..., Ka (sortednondecr
Network flow.Map: First split each pillar into two points.The in point of each pillar points outward to an edge with a capacity of column height.The out point of each pillar is connected to the point at which a column can be reached, and a capacity is a positive infinity edge.The point of Origin is connected to one edge of each column that has an initial lizard.Each pillar that jumps out of the map will have a positive infinity edge to the sink point.Running the maximum flow is the number of liz
http://codevs.cn/problem/1364/
SolvingA look is a short-circuit problem. Set the starting point, end point, press test instructions to add edge. Each floor is annular, the end of the n+1 layer, add edge should be extra careful. A bit of a layered graph. Heap optimization Dijkstra patience to write down. The shortest way to test, but also to test patience.
Code
#include #include #include #include using namespace STD;Const intOO =1000000000, nil =0;intNmMap[ $][ $];structp
From NOI2006, this is probably the first network stream in history.Remember how to build a maximum-weight closed sub-graph. Also remember that the network flow of the number of sides and points must not be easily determined!#include #include #include #include #include #define MAXV 55500#define Maxe 1000005#define INF 0X7FFFFFFFusing namespace Std;struct Edge{int v,f,nxt;}e[maxe];int nume=1,n,m,x,y,z;int G[MAXV],S=0,T,SUM=0,MAXCUT=0,DIS[MAXV];inline vo
" ...) ), then the problem becomes super piano ....1#include 2#include 3#include 4#include 5#include 6#include 7 #definePAU Putchar (")8 #defineENT Putchar (' \ n ')9 #defineCH for (int d=0;dTen #defineLson x->ch[0],l,m One #defineRson X->ch[1],m+1,r A using namespacestd; - Const intmaxn=500000+Ten, maxnode=3000000+Ten, maxm=1000000+Ten, maxt=maxn* -, inf=-1u>>1; - structted{intX,Y,W;TED*NXT;} adj[maxm],*fch[maxn],*ms=adj; the voidAddintXintYintW) { -
How to use:
sz (size) storage subtree size
DP (deep) storage node depth
fa (father) storage node Father
HS (heavy son) storage node heavy son
HF stores the top node of the current node's chain
ID Storage node number
nd (node) stores the current number Corresponding node
Namespace Tree {#define MAXN 100001int SZ[MAXN], DP[MAXN], fa[maxn];int hs[maxn] = {0};void DFS1 (int x, int f, int dep) {D P[X] = DEP, fa[x] =
some 22 nonadjacent lattice, so that the weight of the largest ...Analysis:The most power value independent set problem, the grid diagram, so can black and white dyeing, s to Black point a capacity for the lattice weight of the edge, white point to t even a capacity for the lattice weight of the edge, the black point to the adjacent white point with a capacity of +∞ edge, and then the smallest cut is the minimum point weight coverage, The total weight minus the minimum cut is the answer ...Code
son to add that number, so we will be based on the depth of the odd couple, the time stamp into 2 arrays, the establishment of 2 segment tree/************************************************************************* > File name:cf225-e.cpp > Auth Or:alex > Mail: [email protected] > Created time:2015 April 21 Tuesday 21:11 04 seconds ******************************** ****************************************/#include #include #include #include #include #include #include #include #include #include
How far away?This problem test instructions is, given a tree, each side has a certain weight, q times asked, each time asked about the distance between two points. So you can use LCA to solve, first find the U, v two point of the LCA, and then calculate the distance value on it. Here the calculation method is, note the root node to any point of distance dis[], so that ans = dis[u] + dis[v]-2 * DIS[LCA (V, v)], this expression is relatively easy to understand://==================================
format:For each coach's name, output one line. If the name is correct and is first appeared, output "OK", if the name is wrong, output "wrong", if the name is correct but not first appear, output "REPEAT". (all without quotation marks)Ideas:It is said that the hash can be past, but I still obediently wrote the trie treeWe've built everyone's name into a trie tree.And then run a match.If there are no nodes on the trie and there are no matches, then the point is wrong.If the point to the name is
with three integersu,v andWwhere0≤w≤ Denoting an edge between u and v of Barricade cost w. Outputfor Each test cases, the output of the minimum wood cost. Sample Input14 2 4 1 3 4 Sample Output4Analysis: The shortest cut maximum flow can be obtained;Code:#include #include#include#include#include#include#include#includestring>#includeSet>#include#include#include#include#include#defineRep (I,m,n) for (i=m;i#defineRSP (It,s) for (Set#defineMoD 1000000007#defineINF 0x3f3f3f3f#defineVI vector
Hey hey, I wrote it before. I just suddenly saw it, so I posted it. KMP is used to search for the next [] array and the longest repeated string.
Pku2406
# Include
PKU 1961
# Include
HDU 3746 cyclic nacklace
View code
# Include # Include Using Namespace STD; Const Int N = 100000 + 10 ; Char P [N]; Int NXT [N], M; Void Get_next () {NXT [ 0 ] =- 1 ; Int K =- 1 ; For ( Int I =
with revenue, each augmented path is actually the minimum traffic on the augmented roadso it's not the biggest payoffto run min cutans= Ownership Value and-min cutExplanation: Step 2: If you cut the same selection of this side, then the two students can only cut the edge of the text, otherwise it will be through the INF edge with the meeting point, does not meet the minimum cut#include #include#include#defineN 50101#defineM n*30#defineINF 2e9using namespacestd;intfront[n],to[m],
, where VI (1≤VI≤108) indicating the value of Pond I.Each of the last m lines contain-numbers A and B, which indicates that pond A and pond B is connected by a pipe.OutputFor each test case, output the sum of the value of all connected components consisting of odd number of ponds after removi Ng all the ponds connected and less than the pipes.Sample Input17 71 2 3 4 5 6 71 41 54 52 32 63 62 7Sample Output21HINTTest instructionsGive you a picture, and then ask for the number of points less than 2
is mx[], farthest right end position One intans=0; A intMain () { -scanf"%d%d",n,t); - intb; the inti,j; - for(i=1; i){ -scanf"%d%d",a,b); -mx[a]=Max (mx[a],b); + } - intlast=1, now=1; + intEd; A while(nowt) {//now is the length that is currently covered atEd=0; - for(i=last;i){ - if(mx[i]>ed) { -ed=mx[i];last=i; - } - } in if(ed+1==Now ) { -printf"-1\n"); to return 0; + } -Now=ed+1; ans++; the
sample ... TAT ... Because there are rings ...So we have to delete the point of the ring, and if the point on the ring is not selectable, then the point pointing at it cannot be selected ... What to do? Topological sort?But the topological sort can only judge if there is no ring, cannot judge whether the point is on the ring ... For example, the following picture ...But it's a coincidence that our chart is that all points pointing to the ring are not selectable ... So reverse all sides ... Topo
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.