Topic of the Counting category

Source: Internet
Author: User

Is mainly the first two days were uoj of the hair of Grandpa's problem is not light, the heart is very uncomfortable ah, must work hard,,
The counting class problem is divided into: 1. Combinatorial mathematics and number theory counting
2.DP: State compression DP, plug contour DP, tree DP, digital DP, normal DP
3. Principle of tolerance and repulsion
4.polya principle
5. Graph theory Count
6. Generating functions
7. Other (Spanning tree count, etc.)
This article mainly studies the first 3 content
Consider the basic counting principle: addition principle, subtraction principle, multiplication principle, Division principle
The basic principle of counting: The result is not heavy without leakage
The addition principle is natural, the intermediate process sometimes subtraction principle
Considering the non-direction, the various measures of the graph (spanning tree, etc.) count, state compression DP Solution

Paper: Http://wenku.baidu.com/link?url=A5g_2tVjFJL6aDL8aIdBXrfWr_ Qjspcpbj6qk8yzx97smsmdas4so2pc3qbwfteukobju9oaxnuoqheqz0ojpqhsn5saiq_-3ixnibqw61q
1.bzoj State compression DP (including plug DP, contour DP, repulsion principle, etc.):
1042 1068 1072 1076 1087 1097 1187 1195,1210 1226 1231 1419 1494 1688 1853 1879 1948
2005 2121 2024 2064 2310 2331 2393 2440 2595 2669 2734 2839 2916
3094 3125 3129 3195 3198 3269 3589 3622 3771 3812 3925
4006 4008 4086 4145 4197 4416 4558
Hzwer:http://hzwer.com/category/algorithm/dp/state-compression/page/3
Http://hzwer.com/category/algorithm/dp/state-compression/page/3
1. Title: 4558: [JLoi2016] Fang

by situation: Unac

Key words: Tolerant principle + Classification Discussion

Train of thought: Although the data range is very large, but this kind of deduction point is often to be dismissed, consider how to let out, to seek to include a number of points of the program number
1. Contains a point of (very good statistics) O (K) 2. Contains two points: divided into the same row, the same column, the same oblique line of the scheme, direct violence point to O (k^2) 3.3 or 4 points, the third case of enumeration 2 directly determine the corresponding position is good 4. There could not be more than 4 points, in fact, According to the key point DP is also OK, just some trouble,,,

Complexity: O (k^2)

Summary: Do not be intimidated by the range of data and dare not to let go, the principle of tolerance is not necessarily the complexity of the exponential level
, deepening the study of the principle of accommodating (mathematics)

Note: none

2. Title Name: 4416: [Shoi2013] factorial string

by situation: Unac

Key words: tolerant principle Backpack DP

Thinking: Considering the direct judgment is not good to do, we can turn the decision-making problem into a counting problem, that is, how many different n permutations of the number of strings s, here to use the principle of tolerance, the enumeration 2^n and then ask C (len-num,26), found that the complexity of ultra-high Ah, however, consider the contribution of the discovery Len- Num has only 450 values, so a backpack and then a brute force calculation, where the complexity becomes very strange because of the high precision.
There are some of the principle of tolerance to get rid of the repetition, I can not understand, I understand the principle of the repulsion is not a lump of constraints, considering how the subject to the limit, first select a sub-sequence of s, and then meet the constraints are a belongs to S (n), b belongs to, so we can use the principle of tolerance.

Summary: Limiting abstraction and intuitive feeling (important) for deepening the principle of tolerance and repulsion

Note: none

3. Title: 4197: [Noi2015] Sushi Dinner

Through the situation: Unac (the puzzle) (!!!) )

Keywords: Pressure dp sub-block

Thinking: Forgive me in a long time ago than now still naive when I saw the problem of the solution, although at that time did not see big understand but this problem is not a self made out of it, so sad.
Just keep it and think about it.

Complexity of:

Summarize:

Note the situation:

4. Title: 4145: [Amppz2014]the Prices

by situation: Unac

Keywords: State compression DP

Idea: Optimal value problem, M only 16, so consider the pressure DP. Set F[i][s] represents the first I shop, buy the product set for the optimal value of S, violent transfer, that is, enumerate the remaining not selected collection to transfer, the complexity of ultra-high, seemingly will tle, expressed frustration. My solution is meet in the middle, and I don't know right. The transfer complexity is very high, however, considering that the store is divided into two parts, it must be the number of >= m/2 behind, or vice versa. Then calculate F[0/1][0/1][s], respectively
Represents the first I, after I, the selected collection is the s/not selected collection is S, minimized/or maximized value, so can be violent transfer, because s only,,, what you think,,, Mdzz,
Well, the above is purely my hu, consider, we optimize this tle sb DP, how to optimize it, consider the greedy transfer, found that the collection of items for the s when combined with tolls is the minimum cost, so pre-treatment, transfer when the violent transfer

Complexity: O (n*2^m + 3^m) = O (4*10 ^ 7)

Summary: Can consider greedy optimization transfer

Note: none

5. Title: 4086: [Sdoi2015]travel

by situation: Unac (!!!) )

Key words: Violence

Idea: A slightly strange question, let me think about it.

Note the situation:

6. Title: 4008: [HNOI2015] King Arthur

by situation: Unac (!!!) )

Keywords:

Ideas:

Note the situation:

7. Title: 4006: [JLOI2015] Pipe connection

by situation: Unac

Keywords: State compression DP

Thinking: Consider, found that p small poor, so we can enumerate the set division, that is, which form a unicom fast, considering if only one of the channels directly regardless, then the most useful channel number is 5, consider the set division, we find that as long as the DP out of the set division of the minimum value together to get the answer. Consider direct dp,f[i][s] to indicate the minimum value of the set S unicom with the point edge of the containing point I, consider the violent transfer, the enumeration and I-connected Edge J, enumerate the true subset of S S1, and then f[i][s] = min (f[i][s1] + f[j][s-s1] +w (I,J)), the boundary is F I [s] (s only contains one element) = I and the element of the shortest, so that I can form a ring and can not be the DP egg pain for a long time, and later found that there is no ring, because the enumeration is not empty, so at least 1 per cut, and finally classified as the basic situation, the best write memory search, preprocessing and the shortest-circuiting of all critical points.

Complexity: O (p*m + M * 3^p) (slightly scary)

Summary: Be sure to consider whether the DP will form a ring. Suppose method dp

Note: none

8. Title Name: 1042: [HAOI2008] Coin Shopping

by condition: AC

Key words: tolerant principle Backpack DP

Ideas: The title of the question as the mathematical form of the equation, we can see, only 4 kinds of coins, 4 kinds of restrictions, directly on the capacity of the good, attention to pre-treatment F[i][j] program number, then f[i][j] = F[i-1][j-ci] + f[i-1][j-2 * CI] and so on, notice this Will tle, to accelerate the transfer, considering the form and F[I][J-CI] almost the same, do bad get f[i][j] = F[i-1][j] + f[i][j-ci], when the direct calculation is good.

Summary: note DP acceleration transfer (and the form generally to do poor)

Note: none

7. Title: 1068: [SCOI2007] Compression

by situation: Unac (!!!) )

Keywords:

Ideas:

Note the situation:

8. Title Name: 1072: [SCOI2007] Arrangement Perm

by situation: Unac

Keywords: State compression DP

Idea: How can you feel violent? The length of S is very small, consider the direct state compression dp,f[s][j] means the selected set is S, the remainder is the number of schemes of J, enumerate the remainder as the highest bit of violent transfer is good, notice that there are many are actually equivalent S, so we violent search out all cases then DP, Select Representative S (minimum equivalent) for DP

Complexity: O (2^len*len*d) = O (10^7)

Summary: Sometimes we need a violent approach

Note: When counting, pay attention not to leak

9. Title Name: 1076: [SCOI2008] reward off

by situation: Unac (!!!) )

Keywords: expected DP

Ideas:

Note the situation:

10. Title: 1087: [SCOI2005] Non-aggression king

by situation: Unac

Key words: Pressure DP

Idea: Considering that N is very small, set F[i][j][s] indicates that line I put J King I row of the placement situation when S of the scheme number, enumeration legal s1,f[i][j][s] = SUM (f[i-1][j-num (S1)][s1], preprocessing S1, and then direct DP is good

Complexity: O (n*k*2^n + 2^2n) = O (10^6)

Summary: None

Note: none

11. Title: 1097: [POI2007] Tourist Attractions ATR

by situation: Unac

Keywords: State compression DP

Thinking: Consider running K times SPFA violence to build a new K-point complete map, including the starting point and the K-point, and then you can DP, the topic gave a little limit, the classic DP transfer and the definition of a change is good, remember F[u][s] represents the current in U, has gone set for S, and to meet the topological relationship of the scheme, And then it's good to be legal when you move.

Complexity: O (mk+k*2^k) = O (10^7)

Summary: Attention to mastering the classic model of proficiency

Note: none

12. Title: 1187: [HNOI2007] Magical Amusement Park

by situation: Unac (!!!) )

Keywords: plug DP

Ideas:

Note the situation:

13. Title: 1195: [HNOI2006] Shortest female string

by situation: Unac

Key words: Pressure DP

Idea: Consider, the formation of S, this n string must be in order to intersect or tangent, otherwise you can delete the middle of the character, so the violence to make the longest prefix match, then the order problem, to establish a n point to the graph, the weight of the edge is the matching length, considering, ans = substring total length-coincident part, That is, maximize the edge, become the most classic DP, directly do the line.

Summary: Pay attention to the essence through appearances

Note: none

14. Title: 1210: [HNOI2004] Postman

by situation: Unac

Keywords: plug DP

Ideas:

Note the situation:

15. Title: 1226: [SDOI2009] School canteen Dining

by situation: Unac (!!!) )

Keywords:

Ideas:

Note the situation:

16. Title: 1231: [Usaco2008 nov]mixup2 Chaotic Cow

by situation: Unac

Keywords: State compression DP

Thinking: Consider if the words are not good to do, complement the transformation, seek non-chaotic team, consider direct DP,
F[i][j][s] The number of scenarios, the backward transfer is good

Complexity: O (n^2*2^n)

Note: none

17. Title: 1419:red is good

by situation: Unac (!!!) )

Keywords: probability dp

Idea: probability + game directly equals No.

Note the situation:

18. Title: 1494: [NOI2007] Spanning tree count

by situation:

Keywords:

Ideas:

Note the situation:

19. Title: 1688: [Usaco2005 open]disease manangement disease Management

by situation: Unac

Keywords: State compression DP

Idea: direct DP, definition F[i][s] represents the maximum number of first I disease set for S, violent transfer is good

Complexity: O (2^d*n)

Summary: Pay attention to multi-use bit operation acceleration

Note: none

20. Title: 1853: [Scoi2010] Lucky number

by situation:

Keywords:

Ideas:

Note the situation:

21. Title: 1879: [Sdoi2009]bill's challenge

by situation: UNAC (!!!)

Keywords:

Ideas:

Note the situation:

22. Title: 1948: [Ceoi2006]connect

by situation: Unac (!!!) )

Keywords:

Ideas:

Note the situation:

23. Title: 2005: [Noi2010] Energy harvesting

by condition: AC

Keywords: Subtraction principle dp

Idea: Actually this problem we can completely MO, but relatively troublesome, consider we use subtraction principle count, consider contribution, calculate f[i] mean GCD = i number, g[i] mean I divide gcd number, transfer is obvious, g[i] = (n/i) * (m/i),
F[i] = G[i]-f[2*i]-f[3*i] et cetera

Complexity: O (NLOGN) (harmonic progression)

Summary: Two ways of counting, mastering

Note: none

24. Title: 2121: String game

by situation: Unac (!!!) )

Keywords: feasibility DP interval DP preprocessing string

Ideas:

Summary: None

Note: none

25. Title: 2024: [SHOI2009] Prom

by situation: Unac

Keywords: DP subtraction principle High accuracy

Idea: The problem with that "there is nothing to be afraid of" is the same problem, but just to become at least, to calculate exactly each kind of situation add up good, there is no tolerance principle of practice? I don't know, it's disgusting, it seems to be a high-precision look.

Summary: None

Note: none

26. Title: 2064: Division

by situation: Unac (!!!) )

Keywords:

Ideas:

Note the situation:

27. Title: 2310:parkii

by situation: Unac (!!!) )

Keywords:

Ideas:

Note the situation:

28. Title: 2331: [SCOI2011] Floor

by situation: Unac (!!!) )

Keywords:

Ideas:

Note the situation:

29. Title: 2393:cirno's Perfect arithmetic classroom

by situation: UNAC (!!!) Exercises

Key words: Tolerance theory complexity estimation

The idea: No complexity is estimated, but the positive solution is violence + pruning

Note the situation:

30. Title: 2440: [Zhongshan selection 2011] Total Square number

by situation: Unac

Key words: the principle of tolerance and repulsion

Train of thought: first of all to seek the K large, the two answers to statistics x within the number of satisfied with the condition, the title is equivalent to not contain any prime number greater than 1 factor, consider the principle of tolerance, write a mathematical form, found to make a contribution to the prime is small root n, at the same time, and then consider contributing, when and only and consists of a number of different prime numbers, which allows us to consider the Möbius function so that we can have a pleasant square root n out of the solution.

Summary: Seemingly more complex of the principle of tolerance, write a set form, consider the contribution of integration, complexity can be very low, do not be afraid to use the principle of tolerance.

Note: none

31 Topic Name: 2595: [Wc2008] Tour plan

by situation: Unac (!!!) )

Keywords:

Ideas:

Note the situation:

32. Title Name: 2669: [cqoi2012] Local minimum

by situation: Unac (!!!) )

Keywords:

Ideas:

Note the situation:

33. Title Name: 2734: [HNOI2012] Collection selection

by situation: Unac

Keywords: State compression DP

Idea: Very happy to think out this problem, feel a little cancer.
Consider, we found that if a number x and X is not divisible by 2 or 3, then X * 2^a*3^b form a set of numbers, you can estimate that there are at most O (log^2), but the violent search found only 101, and then consider that these sets are independent of each other, we can separate calculation, multiply it up good, Then it can be found that if the 2^a*3^b sorting, then the answer of each set is a continuous prefix, so as long as the violence to deal with the whole, take the prefix can be, so consider how to calculate a set, the principle of repulsion? No, because the connection form of the restriction is & I try to merge and cross the various sets of transformations have failed, it is possible that the principle of tolerance can not do this kind. Question (thinking!!!) ), once again, I violent search small data, found that although a number of 2/3 is not exactly in front of X, but the difference is not more than 17, so you can state compression DP, save 17 options, F[i][s] Direct violence transfer, legal on the line, so this problem on the perfect solution.

Complexity: O (100 * 2^17) = (10 ^ 7) A bit of a card.

Summary: 1. Separate the relevant content from each other 2. Bold conjecture + violence validation is sometimes the key, and being good at discovering small orders of magnitude is the key point

Note the situation:

34. Title: 2839: Collection Count

by situation: Unac

Key words: Set tolerance principle

Idea: The enumeration intersection is assumed to be K, which contains k elements, set f[k] as the intersection is exactly the number of K, G[k] means the intersection contains the number of K, it is obvious g[k] = (sum) f[s] (S containing K) inversion to get f[k] = (sum) ( -1) ^ (k-num[t]) g[t ], easy to know g[t] = 2^ (2^ (n-num[t)), and then consider the contribution to enumerate NUM, considering that the number of elements for Num is C (n-k,t-k), but there are exactly k elements of the number of sets is C (n,k), so ans = C (n,k) sum (I (I >= k) ( -1) ^ (k-i) C (n-k,i-k) 2^ (2^ (n-i)) direct calculation is good.

Summary: None

Note: none

35. Title: 2916: [Poi1997]monochromatic triangles

by situation: Unac

Key words: Violence

Thinking: Consider the complement transformation, you can expand to more edge number, the discussion on the situation is good

Summary: None

Note: none

36. Title: 3094: [Acm beijing2012]peach Blossom Spring

by situation: UNAC (!!!)

Keywords:

Ideas:

Note the situation:

37. Title: 3125:city

by situation: UNAC (!!!)

Keywords:

Ideas:

Note the situation:

38. Title: 3129: [Sdoi2013] Equation

by situation: Unac

Key words: Tolerance theory Combinatorial mathematics

Idea: Considering the number of variables is very small, can be directly tolerant, and then use the partition method to solve.

Summary: Pay attention to the pros and cons of the problem (it is difficult to reverse (learn))

Note: none

39. Title: 3195: [Jxoi2012] Strange Road

by situation: Unac

Keywords: State compression DP

Thinking: Considering that the data is ordered, affecting only the K-range points, and K is very small, considering state compression, F[i][s] to the first point, I, before the K-point is even degree, the front of the K point is even, the violent transfer enumeration F[i + 1] of the selected set, The guarantee is legal. And it feels so dull all night, my goodness.

Complexity: O ((2^2k) *n) = O (10^7)

Summary: Want DP, first find order relationship (!!! )

Note: none

40. Title: 3198: [sdoi2013]spring

by situation: UNAC (!!!)

Keywords:

Ideas:

Note the situation:

41. Title: 3269: Sequence dyeing

by situation: UNAC (!!!)

Keywords: dp

Idea: F[i]

Note the situation:

42. Title: 3589: Dynamic tree

by situation: Unac

Keywords: Dfs sequence repulsion principle

Idea: Consider the sub-tree maintenance, path query, with DFS sequence maintenance, and consider the K max only 5, the tree chain is not good, but can find the intersection of the tree chain, this is the principle of tolerance.

Complexity: O (2^k*nlog^2n) = O (3 * 10^8)

Summary: To see small-scale data to be sensitive, to transform the answer, to study the DFS sequence and tree-chain split

Note: Distinguish between DFS sequence and tree chain split.

43. Title: 3622: There's nothing to be afraid of.

by condition: AC
+
Keywords: Subtraction principle dp Relaxation thought

Idea: slightly

Note: slightly

44. Title: 3771:triple

by situation: Unac (!!!) ) (generating function, polynomial, number theory)

Keywords:

Ideas:

Note the situation:

45. Title: 3812: Theme

by situation: Unac (!!!) ) (graph theory, CLJ count)

Keywords:

Ideas:

Note the situation:

46. Title: 3925: [Zjoi2015] After the earthquake fantasy Township

by situation: UNAC (!!!) (Probability and expectation topic)

Keywords: is said to be a god problem,

Ideas:

Note the situation:

Topic of the Counting category

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.