Impressions: Depth First has a deeper understanding, just beginning to write the idea of a little confusion, do not know how to write recursion, export also made a mistake, over and over the process of deep understanding.#include #include#includeusing namespacestd;inta[ +],b[ +],c[ +][ +],n,sum,tp=0, tp2=0;voidBFsintTpintl);intMain () {memset (A,0, +); //memset (b,-1,21); while(SCANF ("%d", n)! =EOF) { for(intI=0; i) for(intj=0; j) scanf ("%d",C[i][j]); BFS (0,1); printf ("%d\n", su
Test instructions: Give you 10W numbers, each number is a large number, the range is 1 to 10^30, and then ask you how many ways, each time you choose two number, two number and 2 powerThe following: 10 of 30 times is about 2 100 times, so first pre-processing 2 102 times, then each input a large number, enumeration 2 power to reduce it, and then go to map to find how many solutions, in fact, is a very simple idea, but I have been writing fried, mainly large number of templates is too poor, will
Test instructions: X attacks, Garrosh have y blood, z three blood slave master, and then the slave owner every one of the non-fatal damage will be regenerated a Slave Lord, on the field up to 7 slave owners, ask you the last to kill Garrosh the probability of how much?Problem: DP recursion, the key is how to design the state, the beginning did not think well, was the gold medal ye Hu a sentence with crooked to the shape of pressure, in fact, the state does not need any four-way pressure, in fact
strings of length 2*n, a, B, and then given a 2*n long string c,c string consisting of n strings in A, B, to determine whether a given two string can form C.Analysis:By test instructions, we can list 9 scenarios: Judging if a string in C is compliant with test instructions.Because one of the letters in A, B is up to N to form C, (when a string of a B is greater than n, it can only be taken out of N) in order to satisfy the conditions that make up the C string.
A[i]
A[i]
Title Link: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1507Problem-solving ideas: This is a simulation problem, read so many people's code, I think my code is the simplest, haha, in fact, the score changes in the time to calculate the lamp light number of complex, I was directly violentAC Code:#include #include#include#includeusing namespacestd;Const intm=45000;intc[Ten]={6,2,5,5,4,5,6,3,7,6};Chara[5],b[5];structnode{intx, Y, Z;} T[M];intMain () {intCa=1; while(1) { inti=-1, g=0, h=0,
); the #endif - inti,j,k; in intx, y, z the //for (scanf ("%d", cass); cass;cass--) the //for (scanf ("%d", cas), cass=1;cass About //while (~scanf ("%s", s+1)) the while(~SCANF ("%d",N)) the { thelll=aans=0; Mem (Last,0); Mem (inch,0); Mem (d,0); +scanf"%d",m); - for(i=1; i"%d%d", aa+i,bb+i); the for(i=1; i)Bayi { thescanf"%d%d",x,y); theAdd (x, y);inch[y]++; - } - Tuopu (); theprintf"%lld\n", Aans); the } the return 0; the } - /* t
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1079There is a tree with n vertices, and the vertices are numbered 1, 2, ..., N. For each query that is shaped like a B K, you need to answer whether the point K is included in the path from point A to to B.DFS sequence Euler sequence lca-recent public ancestorAfter reading these two articles will be doneFirst find out the nearest common ancestor P (Because tree path → (a→p→b)) of a, B, we need to find out if there is a point k on this road.Conve
Test instructions: Give you an no-map to determine if there is a ring of length k.Idea: DFS traversal has a ring with a length of k at each point as the starting point. Now in DFS (NOW,LAST,STEP) represents the current point, last represents the previous point of access, step is a record path length counter, and S "I" records the path length from the starting point to the I point. If a point is accessed a second time, then the ring appears, judging the current path length and whether it is the f
equivalent length of the queue memory equivalent to 3 to 4 times times the same intTherefore, we should be careful to use the STL, for the sake of insurance, with the queue when the limit capacity of the data input is not more than 1e7, that is, 1/10int in 32768KB capacity aroundBlack technology using bit arithmetic in the code of Solution 1/2FORD (i,n-1,0) {cin>>x; Start+=xi;}intC=N; For (I,1, M) {cin>>x; For (J,1, X) {C--; End1+=dightC; End2+=(1-dight) C; } dight^=1;}/// if((fr (111))) {an
Rectangleproblem ' s Link: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1547
Mean:give you some 1 or 2 wide planks, and let you put it in a box with a width of two, asking you how long the box is.Analyse:Simple DP, first thought wrong.Time Complexity:o (n)Source Code://Memory Time//1347K 0MS//by:crazyacking//2015-03-29-22.02#include #include#include#include#include#include#includestring>#include#include#include#include#include#defineMAXN 10005#defineLL Long Longusing namespaces
Http://acm.csu.edu.cn/OnlineJudge/problem.php?cid=2071pid=6Test instructions: There is a sequence consisting of n numberRequires a sequence that satisfies Max-minIdea: (I heard that the data big situation can be solved with a monotone stack but I was purely violent)First, enumerate the left bounds and assign Max and Min both to a[i]Then enumerate the right bounds each time to determine whether max-min is less than or equal to KFind the maximum value #include
Topic Link: Click to open the linkTest instructionsA two-dimensional matrix given [0,n] * [0,m]There are k green dots in the matrix.The following K-line gives the green point coordinates (guaranteed that the given coordinates are not integers and 0 Ask:Use a 1-width brush to dye one line at a time or to dye a columnAsk at least a few brushes to useIdeas:A binary match that maps all points to the lower-left coordinate of the square in which the point is located (that is, discarding the decimal pa
Topic Link: Click to open the linkTest instructionsGive the value of the inverse number to find the original sequence (a 1-n arrangement)1, 2, 0, 1, 0 means that the reverse number of 1 is the reverse number of 2,3 is 0Ideas:From the last number, insert the number of a[i] each time it is inserted into the current sequence.Splay Simulation= = This method is relatively straight (WU) view (NAO), other methods do not want to come out.#include The CSU 1555
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.