POJ 3436 ACM Computer Factory (maximum network flow)
Http://poj.org/problem? Id = 3436
ACM Computer Factory
Time Limit:1000 MS
Memory Limit:65536 K
Total Submissions:5286
Accepted:1813
Special Judge
DescriptionAs you know, all the computers used for A
Problem DescriptionWowapps most like to learn English, English class never skip class, but English has not been learned, because the class has been sleeping. Why do you sleep, because he thinks the English word is too long. Now Wowapps has a long, long, long word and wants to compress it. Can you help him?Compression: Replaces consecutive repeating letters with one, see sample for details.InputEnter an n first to indicate the number of words Wowapps give (1Next n lines, each behavior of a string
Problem DescriptionTomorrow will be the English exam, Wowapps is Midnight Oil recite the words. Wowapps found the word difficult to recite, the back one forget. After careful study, Wowapps found that the reason why the word is difficult to recite is because of the appearance of a character, destroying the beauty of the whole word, resulting in poor memory. Wowapps decided to destroy these discordant characters on behalf of the Moon!! (Applause!!) But the exam has entered the countdown, and Wowa
Problem DescriptionEnter an unsigned short integer k[hex.] and P[oct.], the high byte of K as the low byte of the result, and the high byte of p as the result of the high byte to form a new integer.InputK[hex.] and P[oct.]OutputThe operation gets the new integer n.Sample Input0XD9 01117Sample Output200HINTOutput is 16 binary1#include 2 intMain ()3 {4 5 intk,p;6 while(SCANF ("%x%o", k,p)! =EOF)7 {8 intNewint = (p0xff00)| (k0xff00) >>8;9printf"%x\n", newint);Ten }
the DP for all flags can be calculated by traversing it again.The code is implemented as follows:1#include 2#include 3#include 4#include 5#include 6#include 7 using namespacestd;8 9 Const intMAXN = 1e4 +7;Ten intt, N, M, U, V, W; One intDP[MAXN],inch[MAXN]; Avectorint,int>>G[MAXN]; - - voidTopsort () { thequeueint>Q; - for(inti =1; I ) { - if(inch[I] = =0) Q.push (i); - } + intx; - while(!Q.empty ()) { +x =Q.front (), Q.pop (); A intK =g[x].size (); at
Analysis: At the same time calculate the shortest distance and cost, the distance is also to update the cost, but also to store both forward and reverse edges.Note: You cannot use CIN and cout, otherwise you will time out.#include HDU ACM 3790 Shortest path problem (SPFA algorithm implementation)
Analysis: First, the number of strong connected components, then the contraction point, and finally find the final answer.1. Use Tarjan algorithm to find the number of strong connected components.2, the contraction point for another graph, through the Tarjan algorithm to find the results. The degree of each point is calculated in the graph after the indent.3, to find out the minimum cost of each strong connected component.4. The final result is obtained according to the dimension of the graph af
and j), sum = c[j]-c[k-1]The procedure is as follows:#include //#include #include string.h>#defineMAX 1000001intC[max];//This method allows you to calculate the number of the first 1 occurrences of a binary number from right to left.//Example://1 ———— 1//Ten ————//110100 ————//10111 ———— 1//10000 ———— 10000intLowbit (intt) { returnt (-t); //return n (n^ (n-1));}//Modify a number in the array, Delta is incrementvoidModifyintNintDelta) { while(N MAX) { intD; C[n]+=Delta; N+=lowbit (
each set of data, outputs an integer that represents the maximum number of combinations that can be seated on a roller coaster.Sample Input6 3 31 11 21 32 12 33 10Sample Output3AuthorprincesssnowSOURCERPG Practice CompetitionProblem Solving Ideas:It feels like the Hungarian algorithm is similar to the algorithm for maximum flow, and each time it goes to the augmented path to get a lot of other "returns".This blog post is very interesting http://blog.csdn.net/dark_scope/article/details/8880547 v
Analysis: To determine whether a graph is a strongly connected component, which is solved using the Tarjan algorithm.#include HDU ACM 1269 Maze Castle--forward strong connected components (Tarjan algorithm practice)
Problem Descriptionthis day the teacher as a routine to small Hao out a topic: The teacher to small Hao a string, let small Hao will the string in reverse order output. InputThe first line includes a T, which indicates how many sets of test data are:Next T line, each line includes a string (length not exceeding 65535).OutputFor each test data output it's reverse string.Sample Input1oaHoaiX EvoL ISample OutputI Love Xiaohao1#include 2#include string.h>3 intMain ()4 {5 intL,i,n;6 Chara[655
, you is also intelligent enough to tackle this kind of people. You agreed to write only the (integer) Division and mod (% in C + +) operations for him.InputInput is a sequence of lines. Each line would contain an input number. One or more spaces. A sign (division or MoD). Again spaces. and another input number. Both the input numbers is non-negative integer. The first one may be arbitrarily long. The second number n would be is in the range (0 OutputA line for each input, each containing an int
Analysis: Find Jimmy from the office through the Forest back home (that is, from point 1 to 2) The shortest path there are how many, in which to meet if you want to go to a to B this road, then there is a to the end of the distance from a to the end of the distance is greater than B.Solution: SPFA algorithm + memory Deep Search1. SPFA find the shortest path from the end point 2 to all other points2, the memory of Dfs from 1 start to other points deep search, the final result is dp[1].#include HD
Problem DescriptionEnter the year to determine if the leap yearsInputEnter an integer n (multiple sets of data)OutputIf it is a leap year, output Yes, otherwise output no (one row per group of data)Sample Input2000Sample OutputYesMy Code:1#include 2 intMain ()3 { 4 intYear ;5 while(SCANF ("%d", year)! =EOF)6 {7 8 if((year%4==0 year% -!=0) || (year% -==0) ) 9 {Tenprintf"yes\n"); One } A Else - { -printf"no\n"); the } -
Problem DescriptionEnter an octal string, convert it to an equivalent decimal string, and output it in the PRINGF%s format.InputFirst, a positive integer t is entered, indicating that there is a T set of test data (1Next T line, one string per line, representing an octal integer (this integer is no more than 20 bits).OutputFor each test data, output the corresponding decimal string. One line per string.Sample Input11732Sample Output986HINTNote: The given octal number may be large, with a long lo
Problem DescriptionTo print out all the "daffodils", the so-called "Narcissus number" refers to a three-digit number, whose numbers are cubic and equal to that of itself. For example: 153 is a narcissus number, because 153=1^3+5^3+3^3. Output:153?????????InputNoOutputThe number of daffodils, the beginning of childhood. One per lineSample InputSample Output1#include 2 3#include 4 5 6 7 intMain ()8 9 {Ten One inti; A - for(i= -;i +; i++) - the if(I==pow (i
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.