UPD: I really don't want to cheat traffic tat. At first did not pay attention to the total length of the page is written to write a Wang Cang (in fact, at noon often began to Card =) .... The loss of 2h (fortunately, a long time to open a separate article) .... Frighten quickly into two lump .... TAT ..... .....
——————————————————————————————————————————————————————————————————————————————
Write (abused) a full one-month B station on the Usaco of the Golden Group ... Up to now, however, only 100 up and down tat (of course, in descending order of AC numbers) has been written (in addition, it is written with the number of cloud Gods = = 300 Oceans after all)
Probably not to 1\3 is oneself writes, half is has the approximate direction to run to look at the solution, the rest is has no thought to go to see the puzzle to be Dead =
Feel the Gold group problem is more suitable for their current level of qaq ... So basically write down the puzzle to deepen the impression it ... For the comparison of the classic and not familiar with the topic is intended to write another problem (instant digging a big pit)
There are 50 ...
Bzoj 1597:[usaco2008 Mar] Land purchase
Slope optimization starter question. F[i] represents the minimum cost for the first block of land purchased
f[i]=min{
F[j]+max_w (j+1,i) *max_l (j+1,i), (0<=j<i)
}//Max_w (j+1,i) and max_l (j+1,i) represent the maximum value of the width and length of the first block of land in the Block I land, respectively.
First remove the land that is completely covered by the other land (because there is no effect on the answer), and the rest is sorted by width. If the width is sorted in ascending order, the length must be descending (the full cover is removed)
The equation becomes f[i]=min{f[j]+wid[i]*len[j+1]}, (0<=j<i)
The rest is the slope optimization ...
View Code
Bzoj 1699:[usaco2007 jan]balanced Lineup queue
RMQ Nude questions ... Because it does not involve the operation of the interval modification, it can be written by the point tree of the line segment tree (built into a heap).
View Code
Bzoj 1230:[usaco2008 nov]lites Switch Light
Segment Tree Interval modification ...
View Code
Bzoj 1666:[usaco2006 oct]another Cow number game cow's numbers games
Code length know all series: Direct simulation can
View Code
Bzoj 1724:[usaco2006 nov]fence Repair Cutting Board
In turn, it is the merging of fruits. Maintenance of small Gan, each time the shortest two pieces of wood and up, until it becomes a
View Code
Bzoj 1726:[usaco2006 nov]roadblocks Second short circuit
Strict short-circuit ... The shortest short-circuit change: At the same time, the shortest distance to a point and a strict short distance are recorded.
In order to press the constant to the original code length changed a lot (anyway, there is no readability =).
View Code
Bzoj 1231:[usaco2008 nov]mixup2 Chaotic cows
The topic is the number of scenarios that require a disorder to be arranged. The language died early. The data range is obviously like pressure.
F[I][J] Indicates the current selected into row cow's status is I, the last cow number is numbered J Chaos Scheme number, (0<i<2^n,1<=j<=n)
F[0][0]=1;f[i][j]=sum{f[i-2^j][k]}, the absolute value of (S[k]-s[j] >k,j exists in the state i)
View Code
Bzoj 1572: [Usaco2009 Open] work schedule Job
Sort by cut-off time in descending order. That is, the time from the large to the small enumeration, at each point in time to arrange the value of the most, and the deadline at the current point in time work
A specific implementation cannot be enumerated at a point in time: The work that can be done is constant at the point in time between the closing time of the adjacent work
Monotone queue optimization.
View Code
Bzoj 1579: [Usaco2009 feb]revamping Trails Road Upgrade
Hierarchy Chart Shortest Path ... DIS[I][J] indicates that the shortest path length of the J-Bar is updated by the I point.
The k+1 layer diagram is built according to the updated number of edges, and the layer I represents the currently updated (I-1) edge. In addition to extending within this layer, the point of the 1~k layer can be extended to a higher level (update the current edge is 0)
View Code
Bzoj 1708: [Usaco2007 Oct]money cow's coin
Full backpack ... I didn't even see it at first, Wang Cang.
Bzoj 1690: [Usaco2007 Dec] The journey of a cow
01 Score Planning ... The binary answer is mid, which rebuilds the edge of the original (U,v,time) to (U,v,fun[v]-time*mid), and if there is a negative ring in the new image, then the current answer is feasible.
View Code
Bzoj 1717: [Usaco2006 dec]milk Patterns mode of milk production
String http://www.cnblogs.com/czllgzmzl/p/4989723.html
Bzoj 1692: [Usaco2007 Dec] Queue transformation
Greedy... The remaining teams are [l,r], each time comparing L to r this string and r to l this string, which paragraph to choose which paragraph
When comparing the size of a string, you can use hash+ to find the length of the longest common prefix, and then compare the size of the next bit.
hash with unsigned int will not be card ... Touching.. Obvious advantages # #
However, O (n^2) violence can be over tat
View Code
Bzoj 1782: [Usaco2010 feb]slowdown swim slowly
DFS sequence, a cow to go to the point I, equivalent to the points I is the subtree of the weight of +1, query the time to query the point of the cattle to go to the right value
can also be differential, into point modification + interval query, with a tree-like array on the line ...
Too stupid to use a line tree and then be moved by constant cry
View Code
Bzoj 1827: [Usaco2010 Mar]gather Dairy Big Rally
O (n^2) violence is the whole tree traversing through every point.
Consider the assumption that the inconvenient value to the current point I is fasum, how to quickly calculate the inconvenient value of I's son
First preprocessing the total number of cows in the subtree of each point exists size[], then for one of I's son J, all the cows in the subtree not in J will have to walk more from the I->j, while the J-tree cows can walk less i->j This section of the road
nowsum=fasum+ (Cownum-size[j]) *dis (i,j)-size[j]*dis (I,J);
View Code
Bzoj 1592: [Usaco2008 feb]making the Grade pavement trimming
Obviously (see the puzzle to know the Tat) after a section of the road trimming, the height must be the same as the original one of those roads .... So the high degree of discretization will become O (n^2) dp ...
No descent: F[i][j] represents the minimum expenditure of the first I segment, the section I height trimmed to J
f[i][j]=min{F[i-1][k]+abs (H[i]-h[j])}, (K<=J) in the process of transfer and record K on the way
Don't go up and do it upside down
View Code
Bzoj 1725:[usaco2006 nov]corn Field Ranch arrangement
The data range is just like pressure.
F[I][J] represents the total scheme number of the first I row, the first row of grass state is J.
f[i][j]=sum{F[i-1][k]},j states and K-States are legal (not the same row of barren land, and no grass adjacent), and j&k==0 (no upper and lower rows without grass in the same column)
Preprocessing the results of various illegal cases is slower than direct enumeration = =
View Code
Bzoj 1711:[usaco2007 Open]dingin Dinner
Binary graph maximum matching: s even cows, drinks and food even t, every cow to the things it wants to eat even side ... It's a little slower than the Hungarian algorithm with Dinic.
View Code
Bzoj 1668: [Usaco2006 Oct]cow Pie Treasures the riches in pie
Bare DP. F[I][J] means to go to column I, line J maximum Wealth,
F[1][1]=MAP[1][J];F[I][J]=MAX{F[I-1][J-1],F[I-1][J],F[I-1][J+1]}
Pay attention to the border .... No. 0, n+1 rows and 1th columns are initialized to negative infinity Qaq
View Code
Bzoj 1571: [Usaco2009 Open] Skiing ski class
DP,F[I][J] Indicates the maximum number of ski cycles with a capacity value of J after the first I time
f[i][j]=max{
f[i-1][j],//in the open and decadent
f[I-dmin[j] [j]+1,//first sort the ramp according to the required capacity, Dmin[j] indicates the required capacity value <=j the minimum required length of the ramp
g[I-l[k]],//K class (subject to Lesson = =), G[i] = maximum value in f[i][1..100]
}
Code ugly can't bear to look straight ...
View Code
Bzoj 1715: [Usaco2006 dec]wormholes Wormhole
There is no negative ring in the inquiry chart ... (Return to the past must be back to the beginning and time is earlier than the departure time)
DFS version of SPFA Award negative ring.
View Code
Bzoj 1596: [Usaco2008 Jan] Telephone network
Tree-shaped DP: Http://www.cnblogs.com/czllgzmzl/p/5064626.html
Bzoj 2442: [Usaco2011 Open] mowing the lawn
Monotone queue:
Maximum efficiency = = Total efficiency-minimum loss efficiency. F[i] Represents the first I-head cows, because there can be no continuous k-cows and loss of the efficiency of the minimum value (I cattle do not arrange).
f[i]=min{F[j]} +e[i], (i-j<=k)
View Code
Bzoj 1233: [Usaco2009open] Hay Heap Tower
Slope optimization ...
Looked at others (seems to be Wshjzaa?) ) to understand the Tat http://www.cnblogs.com/sagitta/p/4650681.html
Note: The final point seems to have a place < and > hit the reverse? (or my Chinese is not good.) )
View Code
Bzoj 1707: [Usaco2007 nov]tanning Distributing sunscreen
Greedy.. Http://www.cnblogs.com/czllgzmzl/p/5064620.html
Bzoj 1709: [Usaco2007 oct]super Paintball Super Marbles
A rare silly question. Can O (n^3) no brain violence ...
Or preprocessing, the number of opponents in each row, column, and diagonal on the read-in process ... And of course, the number of opponents on each point.
The number of opponents that a shot position (x, y) can hit is the number of opponents in line X + the number of opponents in line Y + the number of opponents on the two diagonal -3* ((x, y) Number of opponents on this point)
View Code
Bzoj 1576: [Usaco2009 Jan] Safe road via travel
And check the correct posture. Http://www.cnblogs.com/czllgzmzl/p/5064758.html
Bzoj 1593: [Usaco2008 Feb]hotel Hostel
More normal line tree problem ... Maintain a range of only 0 and 1, the longest 0 length, the longest 0 length from the left, starting from the right
Each time to find the interval position, if the Shari long enough to go to the left subtree to find, or try to cross the section of the left and right sub-tree, the last to go to the tree to find. (no solution direct output 0)
If the interval is modified, a marker is maintained, indicating that the current interval is covered (guests are booked, the guest is emptied, and has been passed)
View Code
1 a touching tat
Bzoj 1697: [Usaco2007 feb]cow sorting cattle Sort
Permutation group: It is still not replacement group Qaq ... But at least the problem can be understood qaq ...
A lump on the internet. Because POJ also has = =
View Code
Bzoj 1828: [Usaco2010 Mar]balloc Farm Assignment
The individual requests are sorted by the right endpoint from small to large. Then directly to meet the ... That's it .... As to why this greedy is right. TAT
Set the interval around the end of l[],r[] ...
Because it is sorted by R: If the current interval is inserted and affects a later interval, then the insertion of the current interval is better than that of the affected interval.
And before inserting the current interval we have tried to satisfy the smaller interval of R, so the current interval has no effect on the previous interval.
View Code
Bzoj 1589: [Usaco2008 Dec]trick or Treat on the Farm collection of sweets
is to seek the total number of subsequent nodes ... Because the whole picture is made up of several base rings, we can use Tarjan to do ...
But because it is the base ring inward tree (same as this year noipd1t2). Starting from a certain point, you will go all the way to the ring where it is connected, and it will have the effect of shrinking point.
Just open a stack to record the current path, to record whether a point is in the stack. Note that the point at which the number of subsequent nodes has been calculated will not have to go.
View Code
It was a long while ago, still being trampled on .... Know just think of a Boolean array without opening to get 200ms ... plus an output optimization. 176ms at a moment = = touching
Why do I use register int more slowly every time
Bzoj 1754: [Usaco2005 qua]bull Math
High-precision multiplication ....... The title of the topic to cover the scope of such a .....
View Code
Bzoj 1770: [Usaco2009 nov]lights
Gaussian elimination solution or equation set .... Free meta-Violence enumeration + optimality pruning = = ...
Say free yuan ah what has not understood ... Math will be a little more slowly after that (already countless times so said Tat
View Code
Copied the yellow seniors code. Cover face
Bzoj 1691: [Usaco2007 Dec] Picky foodie
A bit like bzoj1828 ... Are all two qualifying conditions, although a little different = =
The cows are sorted in ascending order by the required lowest price, and the grasses are sorted by price.
Enumerate the grasses, each of which allows the cows that can accept it to eat the most freshness-demanding cows.
The specific thing is to use a balance tree to maintain the demand freshness of the cows that accept the current price, which is getting more and more. Each forage is found in the tree by freshness.
View Code
Hand hit treap slower than the STL = =
Bzoj 1753: [Usaco2005 qua]who ' s in the middle
Title................
View Code
Add a fast read-in ratio not added to the slow is what situation = =
Bzoj 1574: [Usaco2009 Jan] earthquake damage damage
This means that for each point of the report, find a punctuate to surround it (with 1 points blocked). Clearly (and Qaq) This punctuate is the point adjacent to all points (of course, the adjacent points may also be reported points, but in short, these points can not be reached).
Because the inner circle can not reach the point, we want to make the circle and circle of the least points. So the smaller the circle, the better.
The adjacent nodes of each reported point are set to be unreachable, and the number of points to be reached in the last statistic is good.
View Code
Bzoj 1584: [Usaco2009 mar]cleaning up cleaning
Dphttp://www.cnblogs.com/czllgzmzl/p/5066443.html
Bzoj 1710: [Usaco2007 open]cheappal cheap palindrome
Because the last to form a palindrome string ... For palindrome to delete a letter and add the same letter in the corresponding position is equivalent = =
So the cost of harmonizing a letter is min (delete the letter fee and add the letter fee). (recorded as cost[])
Next is the interval DP ... F[I][J] represents the minimum cost of turning the letter I ~ J of the original string into a palindrome. The original string is s
f[i][j]=min{
F[i][j-1]+cost[s[j]],f[i+1][j]+cost[s[i]],
F[i+1][j-1], (S[i]==s[j])
The final answer is F[1][M]
View Code
Bzoj 1703: [Usaco2007 mar]ranking the Cows cow rankings
Use STL ... Good tune Bitset ...
Build the diagram by the given size relationship. Find out the number of cows per cow I can determine num[i], the answer is total logarithm-known relationship logarithm.
View Code
Why is the same tune bitset I slow so much tat
Bzoj 1578: [Usaco2009 Feb]stock Market
Look at the old driver's puzzle ... Http://www.cnblogs.com/JSZX11556/p/4664348.html
Quote: "We assume that the next day after the purchase of the sale (do not sell can also be seen as a sell and then buy again), this becomes a complete knapsack problem, the stock price for volume, the second day of the stock price-today's stock price for value .... Then just one day dp ... ".
View Code
Bzoj 1598: [Usaco2008 Mar] Bull Run
Ask for a short-circuit of K. See KPM Uncle's code just know can lazy out new realm ...
Maintain the SPFA queue with the priority queue (in fact it becomes a heap-optimized dij). One point out of the team K times when we came to K short-circuit ....
View Code
Bzoj 2060: [Usaco2010 nov]visiting cows visiting cows
Finally, it's a stupid question ... A prom without a boss. Tree Dp,f[i][0] Indicates that I is the root node, I do not select, the maximum number of points that can be selected, F[i][1] indicates that I is the root node, I select, the maximum number of points can be selected.
f[i][0]=sum{Max (f[j][0],f[j][1])}, (J is the son of I); f[i][1]=sum{f[j][0]}, (J is the son of i)
View Code
Bzoj 1702: [Usaco2007 mar]gold Balanced lineup Balanced queue
and bzoj4236 the same idea ... The prefixes of various color numbers are obtained and are differential. If the results are equal after the difference between the two positions, the number of colors is equal between the two locations.
Can be on the hash ... However, the card is often unable to be firmly stepped on the TAT
View Code
Bzoj 1704: [Usaco2007 mar]face the right-turn automatic turning machine
If K has been determined, the minimum number of judgements can be obtained by O (n). M: Sweep back once, if a cow is standing on the back of a point I, turn the i~i+k-1 head cows. Because this time does not turn the words later will not be able to turn ...
Pay attention to the determination of no solution ... If the first cow is standing back and i+k>n (that is, there is no K-head cow can turn) there is no solution ...
Interval modification, single-point query ... This can be used in differential. Because only the forward and the latter two kinds, it will be directly different or a bit better. Time complexity O (n*k)
View Code
Bzoj 1776: [Usaco2010 Hol]cowpol Cow politics
(TAT) Conclusion: the longest path within a political party must have an endpoint that is the deepest point in the political party. After all, the diameter of the tree also has an endpoint on the leaf node?
First, DFS will find the deepest point of each party and then ask for the maximum distance from the other points of the party. The distance between two points on the tree dis (i,j) =depth[i]+depth[j]-depth[lca (i,j)]*2.
Total time complexity O (NLOGN) ... For the LCA part of the test doubled and chain-cut two .... The code is about the same length, but the multiplication is much slower qaq
View code//Chain profileView code//Multiplier
Bzoj 1700: [Usaco2007 Jan]problem solving solving
Dp.. Http://www.cnblogs.com/czllgzmzl/p/5068024.html
Bzoj 1734: [Usaco2005 feb]aggressive cows Angry cow
Silly question. Two-point answer + judgment .... Each time two separate an answer mid, greedy division, see if you can draw out the C paragraph
View Code
Bzoj 1741: [Usaco2005 nov]asteroids through the asteroid swarm
Binary graph maximum matching ... There are asteroids (i,j), with an edge of I to j+n.
Dinic is still slightly slower than Hungary.
View Code
Bzoj 1705: [Usaco2007 nov]telephone wire Erection Telephone Line
Dphttp://www.cnblogs.com/czllgzmzl/p/5068259.html
Bzoj 1783: [Usaco2010 jan]taking Turns
A little game-related? Http://www.cnblogs.com/czllgzmzl/p/5069730.html
Water problem of Bzoj Usaco Gold Group (1)