Using Tarjan to find strong connected components, a DAG is formed after a strong connected component point has an equivalent contraction point, and a number of points a with a degree of 0 are calculated.With a size of 0 B, take one of them. A case in which the number of strongly connected components is 1.It's easier to read the Tarjan algorithm later.#include using namespacestd;Const intMAXN = 2e4+5;Const intMAXM = 5e4+5;inthead[maxn],nxt[maxm],to[max
ExercisesTree-shaped dp+ backpackDP[I][J] Indicates that I is the root, preserving the minimum number of edges required to be deleted by J nodesThe default 1 is the root. At the end of the calculation, 1 of the root of the tree should be added 1 (Cut off the Father node)Be aware of initializing .....Code:#include #include#include#includeusing namespacestd;#definePB Push_back#defineMP Make_pair#defineSe Second#defineFS First#defineLL Long Long#defineCLR (x) memset (x,0,sizeof x)#defineMC (x, y) m
vertex is the in point, and the bottom-right corner is the out point (network flow splitting idea).Build edge to find the shortest possible.By the way, the two types of Dijkstra have been tested, and this version, which is not commented out, is about 200ms slower than the commented version, and it seems that the inq judgment of the large constant is more time consuming than the high-constant priority queue.1 /*by Silvern*/2#include 3#include 4#include 5#include 6#include 7#include 8#include 9 u
son a father, and the father becoming a son, the conclusion is exactly the same, but the number of child nodes has changed.But d[i]=2* (N-siz[i])-1, and finally the read-in edge processing, each jump to the position of V to continueAnd then you'll find that the decimal is feint 23333Code#include using namespacestd;#defineN 100010#definell Long Longintt,n,m,q,cnt;intdep[n],f[n][ -],first[n];ll Up[n],down[n],siz[n];structemail{intu,v; intNXT;} E[n*4];inlinevoidAddintUintv) {e[++cnt].
attached to two cut points, one can not be from another to the other), the answer is tired by the conditions of the Unicom block points. ↑ input Data read in is the number of sides, silly as a point, read into the wrong, but also always check the problem of the algorithm ... ↑wa to fly after the anger to see the key, code to change and Tunix the basic same, only to find read into ... (Hope Day)1 /*by Silvern*/2#include 3#include 4#include 5#include 6#include 7#include 8 #defineLL unsigned long
The idea is actually very good to think: is backwards maintenance and check set.However? The details are super-large.First, each node can be attacked multiple times, just the one that started the attack.Second, consider the dependencies of a clear and checked set.#include #include #include #define Maxe 950050#define MAXV 950050using namespace Std;struct Edge{int v,nxt;}e[maxe];int G[MAXV],N,M,K,X,Y,NOW[MAXV],ANS[MAXV],CNT=0,NUME=0,FATHER[MAXV],FIRST[M
Ah, this is a code editor. I just found out today.Chain water problem. Maintains the color of the interval left and right endpoints.#include #include#include#include#defineMAXV 200500#defineMaxe 200500#defineMAXN 805000using namespacestd;intn,m,num[maxv],x,y,root=1, nume=0, tot=0, cnt=0, G[MAXV];intDIS[MAXV],TOP[MAXV],FATH[MAXV],SIZE[MAXV],SON[MAXV],W[MAXV],FW[MAXV];intLS[MAXN],RS[MAXN],LPOS[MAXN],RPOS[MAXN],LAZY[MAXN],SUM[MAXN];inta,b,c;BOOLVIS[MAXV],FFF[MAXV];Chartype[5];structedge{intV,
following N rows M column is used to describe the number matrix"Output Format"How many value gems can be obtained from the output"Sample Input"2 21 22 1"Sample Output"4SourceYiu Jinyu's original problem, modified You can find some details that you don't need to think about.The Hubo paper has a detailed answer to this question.1#include 2#include 3#include 4#include 5 using namespacestd;6 Const intmaxn=10010;7 Const intmaxm=800010;8 Const intinf=1000000000;9 intCNT,TOT,FIR[MAXN],FRON[MAXN],DIS[
) Putchar (IW)TPR InlinevoidWrite (Ra o,Charc ='\ n') { if(!o) PC ('0'); if(O 0) o =-O, PC ('-'); while(o) wr[++ rw] = o%Ten, O/=Ten; while(rw) PC (WR[RW--] +'0'); PC (c); } TPR InlinevoidCmin (RA a, RA b) {if(A > B) a =b;} TPR InlinevoidCmax (RA a, RA b) {if(A b;} TPR InlineBOOLCkmin (RA a, RA b) {return(A > B)? A = B,1:0; } TPR InlineBOOLCkmax (RA a, RA b) {return(A 1:0; }}using namespacestd;using namespaceRemoon;#defineSid 300050#defineOID 12050000intDfn[sid], sz[sid];intN, R, M,
How much output meets the requirements of the city (S,t).
Input example
5 3 61 2 32 3 33 4 24 5 1
Output example
6
Other Notes
Cities to (2,3), (1,3), (2,4), (2,5), (3,5) meet the requirements, a total of 61111
The puzzle: Will write a point of treatment ...First of the complement set conversion, not the same subtree = total-in the same subtree, then is the path two paragraphs in the same
, the Moore operation must be performed on the array size and size. Until the loop goes to a [0].
If a [1] is not processed at last, put a [1] into temp to repeat the above process. Math can prove that the number of times used cyclically is gcd (size, I). The size is N in the description, and I is rotate from the I element.
CodeWrite as follows:
[CPP]
View plaincopyprint?
# Include
TemplateTypenameT>
VoidSwap (T A, T B)
{
T c =;
A = B;
B = C;
}
IntGcd
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.