punch

Today is May 3. From today onwards, I will punch a card every day, and update it between 8:00 and 10:00 in the evening, and record what I have learned throughout the day.

May 3

1. min-max tolerance

Tolerance and exclusion apply between min and max, there are

$$\max S = \sum_{T \subset S} (-1) ^ {|T| - 1} \min T$$

$$\min S = \sum_{T \subset S} (-1) ^ {|T| - 1} \max T$$

As for the proof, I consider the k-th largest as the minimum number of times to be counted, as

$$\sum_{i = 1} ^ {k} \binom{k - 1}{i - 1} (-1) ^ {i - 1} = [k = 1]$$

[BZOJ 4036] Each time the number $[0, 2 ^ n)(n \le 20)$ is generated, the probability of generating $i$ is $p_i$ , and the sum is $2 ^ n - 1$ after asking how many times to expect.

Get all, you can see the max of the acquired time. The min of a set can be regarded as the expected number of times to select a certain set, which can be converted into 1 divided by the probability of obtaining a certain set.

$$E(\max S) = \sum_{T \subset S} (-1) ^ {|T| - 1} \frac{1}{\sum_{i \cup T \ne \emptyset} p_i}$$

So probably deal with $f_T = \sum_{i \cup T \ne \emptyset} p_i$ first, and then directly sum with the tolerance and exclusion coefficient. $f_T$ can consider using the principle of subtraction first, consider that the intersection is empty, then take the complement of $T$, and consider the subset sum.

[Classic problem] $n$ kinds of stamps, each time with equal probability, how many times can you expect to get all $n$ kinds of stamps. By doing this twice, an interesting identity can be derived:

$$\sum_{i = 1} ^ n \frac{1}{i} = \sum_{i = 1} ^ n (-1) ^ {i - 1} \binom{n}{i} \frac{1}{i}$$

I haven't thought of other good combinatorial proofs, yay gives an algebraic proof that differences are equal, f(0) is equal. Probably some kind of promotion or something.

[HDU] Endless Spinning: A sequence of length $n$, each time an interval is dyed black, how many times do you expect to be completely black? For the expected number of operations that require a certain position in the subset $S$ to become black, considering the probability of the subset becoming black, considering the probability that the subset does not become black, it is $\sum \binom{b_i}{2}$ , So the formula is

$$\sum_{S \subset [n]} (-1) ^ {|S| - 1} \frac{1}{1 - \frac{\sum \binom{b_i}{2}}{\binom{n}{2}}}$$

Using a DP to describe, the state I designed is the current last i-th position black, $\sum \binom{b_i}{2} = j$ $(-1) ^ {|S | - 1}$ sum. 

I thought about it a little bit, and I think that min max tolerance can probably be extended to a form like kthmax.

Assume

$$\text{kthmax}(S) = \sum_{T \subset S} f(|T|) \min(T)$$

Considering the number of times the element with the largest $x+1$ is calculated, we have

$$\sum_{i = 0} ^ x \binom{x}{i} f(i+1) = [x = k - 1]$$

The binomial inversion is

$$f(x+1) = (-1) ^ {x - k + 1} \binom{x}{k - 1}$$

$$f(x) = (-1) ^ {x - k} \binom{x - 1}{k - 1}$$

so

$$\text{kthmax}(S) = \sum_{T \subset S} (-1) ^ {|T| - k} \binom{|T| - 1}{k - 1} \min (T)$$

According to this principle, I can design the following question.

【Original question】$n, m \le 1000, n - 10 \le K \le n$ , there are $n$ stamps, the probability of getting the $i$ stamp is $\frac{p_i}{m}$ , ask how many times to expect to get $K$ stamps, and the answer is modulo $998244353$.

Apply kthmax, and then use the expected linear properties to expand, then it is equivalent to asking the expected number of times a subset is selected, which becomes one part of the probability, the formula is easy to write, and then you can design a $O(nm K)$ The DP of , for transfer, one of the dimensions of the equation is related to the lower index of the number of combinations.

2. Linear basis for an interval

The linear basis of the interval $[l, r]$ can be processed quickly in $O(bit). If $l+2 \le r$ , then $l \le x \le x+1 \le r$ must be found, and $x$ is an even number, so the lowest bit is arbitrary, and only the high bit needs to be recursed. If $l+1 = r$ , then insert the two numbers directly. If $l = r$ , insert this number.

Given two sequences $l[], r[]$ , $l_i \le r_i$ , now ask the linear basis of the interval of the interval. . . After thinking about it, I found that I can still only set a line segment tree to achieve the complexity of three logs. I didn't expect how to continue to optimize, but there are some constant optimizations.

3. "2017 Multi-University Training Contest 1" Given a tree with $100000 $ points, sum the different chromatic numbers on all paths.

Considering the contribution of each color, count the number of paths that pass through this color, and convert to the number of paths that do not pass through this color. Consider enumerating each point, then enumerating its successors, and continuing to search, without passing through points with the same color as the initially enumerated points, a total of $x$ points are scanned, contributing $\binom{x}{ 2}$ , and then special consideration is given to the points outside the LCA of all points of this color. You can do all the colors at one time, and directly perform a DFS on this tree. sum[x] indicates how many points are removed after removing all the DFS-completed subtrees whose color is x when the DFS reaches the current position. Just use the data to count the answers, and maintain the data. Personally, I think this thread is quite clever.

May 4th

fever.

May 5th

fever.

May 6th

Half a day is spent on fever, and half a day is spent learning something.

1. 2-SAT related

The mapping of 2-SAT should be sufficient and necessary to take advantage of transitivity.

2-SAT determines whether there is a solution based on whether the two points are in the same strongly connected component. The 2-SAT construction solution, directly taking the smaller of the two strongly connected components, can be proved according to some properties and symmetry of the DFS order.

"BZOJ 3495" Riddle: Given a graph with 100,000 points and 200,000 edges, the points are divided into several point sets, each point set is required to select a point, and at least one endpoint of any edge is selected, ask whether There is a solution. Consider 2-SAT, where each point includes the possibility of choosing or not choosing. For the limitation of choosing one point per point set, consider connecting i1 to all j2 , construct 2n prefix and suffix auxiliary points, and optimize the number of edges to be linear.

In general, it is a model where one and only one point is selected in a set, so the above model can be used for optimization. Sometimes you can also use line segment trees, Trie, etc. to optimize the mapping, in short, they are all obvious things.

2-SAT has a kind of routine on the tree, "Mythlogical - change": given a tree with 1000 points, there are 1000 gifts, each gift is at a certain point, and satisfies the requirements of several gifts x and y. The path passes through the restriction of point c, or the LCA of gift x and gift y is point c, construct a set of schemes.

Let Vi, j denote whether gift i is in the j subtree. Satisfy the restrictions on the tree first. If it is in the current subtree, then it is in the parent's subtree and not in the sibling's subtree. This condition is sufficient and necessary. For the connection edge that is not in the sibling subtree, consider using previous trick. Then the path of gift x and gift y passes through point c, which is equivalent to gift x and gift y in different subtrees of point c, so if x is in the successor v subtree of point c, point y is not there, if point x is not in the subtree of point c In the subtree rooted at c, the point y is there. The LCA of gift x and gift y is point c, then point x and point y are required to be in the subtree rooted at c, if x is in the successor v subtree of point c, point y is not in.

2. Partial order mapping

"GDOI 2018 Day 3 Prob 1" Given three dimensions, if i has two dimensions greater than j, then you can use i to eliminate j, and ask how many points may be kept to the end.

If i can eliminate j, then i, j are connected, and the question becomes which points can be used as the root node of a tree subgraph. Comparable pairwise, they will be connected to form a competition graph. The competition graph is reduced to a chain, and only the point in the first strongly connected component can be used as the root of the tree subgraph. Enumerate two dimensions, use a persistent segment tree to optimize the edges, run Tarjan, and take the last strongly connected component with points between 1 and n.

In short, the construction of two-dimensional partial order can be assisted by a persistent line segment tree. Each time it connects to several line segment tree nodes corresponding to the prefix, and then the information of the current node is also added to the persistent line segment tree. Extending to the three-dimensional partial order, consider CDQ divide and conquer for one of the dimensions, and do the same for the remaining two dimensions.

Another problem related to the competition graph is that the competition graph has a Hamiltonian path, and the strongly connected competition graph has a Hamiltonian circuit. I can combine such a problem: three-dimensional, if i has two dimensions greater than j, you can use i to eliminate j, Please construct a longest elimination sequence. I know that the length of the longest elimination sequence must be n, and the construction can also be violently constructed, and the time complexity is O(n ^ 2).

3. "AGC 003d" Anticube: Given 100,000 numbers within 10 ^ 10, select as many numbers as possible so that the product of two pairs is not a cube.

Analytical product is not cube, it is easy to think of prime number decomposition, the exponent of each prime number can be simplified to between 0 and 2 first. When p is constant, pq is uniquely determined for the q of the cube, in other words, it corresponds to the numbers of the cubes one-to-one, so the approach is roughly to add the max of the number of occurrences for each logarithm. When simplifying, consider that the prime numbers to be simplified satisfy p ^ 3 < 10 ^ 10 , so only enumerate p < 10 ^ {10 / 3} . When finding the complement, for p ^ 3 < 10 ^ 10 , perform brute force complement, and the remainder of the decomposition can only be p ^ 2 , p, or pq , and the complement can be processed by judging whether it is a perfect square number.

In addition, the value of the complement of this question may explode long long, the correct way is to not deal with it, because we don't care what the value is, only the value is different.

It is easy to generalize the problem to the case where the product of pairs is not the fourth power, enumerate to 10 ^ {10 / 4} when simplifying, and enumerate to 10 ^ {10 / 3} when calculating the complement, so It's just coincidence that both enumerate to 10^{10/3} the same in the original question. .

May 7th

1. Determine whether a point is inside a polygon

"PE 201": Given 1000 triangles, determine whether the origin is inside the triangle or not. The way to judge is to see if they are all on the same side, that is, whether Ai × Ai+1 >= 0 is true, or whether Ai × Ai+1 <= 0 is true.

Original question: Given a number of raw materials whose specific gravity is xi + yi + zi = 100%, and a number of each raw material, ask whether it is possible to synthesize a product whose specific gravity is X + Y + Z. Retain two dimensions, the part that can be synthesized is inside the convex hull, find out all the points of the upper convex hull and all the points of the lower convex hull, for each query, divide the upper convex hull and the lower convex hull into two, and find Y corresponding to x = X on the convex hull, and then judge whether it is in the interval.

In general, if you want to determine whether a point is inside a concave polygon, then a ray is drawn from this point. If there are an even number of intersections with the polygon, it is inside, and if there is an odd number of intersections with the polygon, it is outside.

2. "2017 Multi-University Training Contest 1": There are 10 positions, and the initial value of each position is $n = \sum_{i = 1} ^ {10000} p_i ^ {e_i}$ , satisfying $\ sigma e \le 300000$ , operate on each position each time, change the number of this position into a true factor, and end when a certain position becomes 1, ask the number of solutions ending at each position $998244353 $ modulo.

analyse as below:

It is not difficult to think of an auxiliary problem: let $f(i)$ denote the number of solutions for which $n$ happens to become $1$ in round $i$.

First consider the relationship between the original problem and the auxiliary problem. Currently, the number of solutions that consider the xth position as the termination position, and the enumeration ends at i rounds, then the first x+1 positions can be regarded as the i+1th round. end, the following positions can be regarded as the end of the i-th round, so the answer for the x-th position is $\sum_i f ^ {x - 1}(i+1) f ^ {n - x + 1} (i) $ .

Now consider how to solve $f(x)$, notice that each factor is independent, and $k$ has every chance to turn each index into $0$, which can be regarded as a board, and then a generalized Tolerance, you can get

$$f(x) = \sum_{k = 1} ^ x (-1) ^ {x - k} \binom{x}{k} \prod_{i = 1} ^ m \binom{e_i + k - 1}{k - 1}$$

$f(x)$ can be obtained by direct convolution.

Note that the sum of $e_i$ is $300000$, so the number of values ​​is $O(\sqrt n)$, so directly brute force $\prod_{i = 1} ^ m \binom{e_i + k - 1}{ k - 1}$ .

summary:

(1) The first x+1 positions are not over, but I can neatly think of the problem as "after taking the first one, the rest must be taken", so each position is independent.

(2) "A number, every time it becomes a factor of it, and ends when it becomes 1", you can look at each prime factor separately, and reduce the index each time. If it ends x times, it is equivalent to every x- 1 block edition.

(4) The sum of $\sum e$ is $300000$, the implicit condition is that the number of types of $e_i$ is $\sqrt 300000$, and then it is a big violence.

Similarly, remember that there was a certain question $fgh \le 10000$ before, then there is $f \le 21$ , and then violently enumerate $f$ , there is a quick way to do the remaining two dimensions.

3. Pentagonal Number Theorem

The pentagon numbers are sorted from small to large, which can be described as..., 1 / 2 i (3i - 1) , 1 / 2 i (3i + 1) , ... , which can be easily preprocessed when implementing order.

$$\Phi(x) = \prod_{i \ge 1} (1 - x ^ i) = \sum_{i \in \mathbb{N}} (-1) ^ i x ^ {\frac{1}{2} i (3i + 1)} = 1 + \sum_{i \ge 1} (-1) ^ i x ^ {\frac{1}{2} i (3i \pm 1)}$$

The pentagon number has only $O(\sqrt n)$ items in the first $n$ item, so it can be violently inverted, violently convolved, violently XXX, in short, for the operation of polynomials, the number of items can be correlated, if the number of items Not much, then it can be violent.

Number of splits:

$$\prod_{i = 1} ^ n (1 + x ^ i + x ^ {2i} + ...) = \prod_{i = 1} ^ n \frac{1}{1 - x} = \frac{1}{\Phi(x)}$$

Original: Given $n$ , find the number of permutations with $0, 1, ..., n-1$ in reverse order in the $n$ permutation. The number of inversions of $i$ is $[0, i)$, so the direct column generation function

$$\prod_{i = 0} ^ n (1 + ... + x ^ {i-1}) = \prod_{i = 1} ^ n \frac{1 - x ^ i}{1 - x} \equiv (\sum_i \binom{n + i - 1}{i - 1} x ^ i) \Phi(x) \pmod {x ^ n}$$

Split numbers so that each number occurs less than $k$:

$$\prod_{i = 1} ^ n (1 + x ^ i + ... + x ^ {i(k - 1)}) = \prod_i \frac{1 - (x ^ k) ^ i}{1 - x ^ i} = \frac{\Phi(x ^ k)}{\Phi(x)}$$

Split numbers, all numbers are not repeated: This is a special form of the previous question, which can be done directly with the method of the previous question.

4. Replacement related

"2017 Multi-University Training Contest 1": Given $n = 100000$ permutation $A$, and $m = 100000$ permutation $B$, ask how many $[0, n)$ to $[0 , m)$ , satisfying $f(i) = B_{f(A_i)}$ .

The Main Idea of ​​this question is to regard a permutation of $n$ as a permutation, and the rest is done.

Summary (1): How can the sequence $a_1, a_2, ..., a_n$ usually be viewed? It can be seen as a sequence of numbers, with one number at each position. It can be viewed as n points on a two-dimensional plane. It can be seen that there is a stack of blocks with height i at the ith position. In the case of permutations, it may be counted using properties where each number occurs only once, such as the three-dimensional partial order of the permutation. It is quite possible to think of permutation as a permutation, especially when it comes to more complex mappings.

Classic problem: For an n-ary permutation f, given f^2, construct an f. The original permutation is undoubtedly an important auxiliary element. Considering that the size of the original permutation cycle segment is odd and even, we will continue to discuss it, and split the new permutation into several cycle segments. Get up, and the odd-numbered ones create themselves directly.

Today is basically used to think about such a generalization: for an n-ary permutation f, given f^n, construct a f, and ask how many f are there, modulo 998244353. The original permutation of size $a$ is decomposed into $(a, n)$ permutations of size $\frac{a}{(a, n)}$. For a new permutation, decompose it first, and let c(b) denote the number of permutations of size b. Consider enumerating all b , and try to merge. Consider how many things of size b can be merged, let the number be d, then $(b, \frac{n}{d}) = 1$, so $d = (n, b) k$ , if $(n, b) \nmid c(b)$ , then nothing can be said, otherwise it can be constructed. As for the number of schemes, let $f(x)$ denote the number of schemes that combine $x$ permutations of size $b$ several times, then $f(x) = \sum_{i = 1} ^ x \ binom{x - 1}{i - 1} f(x ​​- i) g(i)$ , $g(d)$ represents the number of solutions to combine $d$ things of size $x$, if $(n, b) \nmid d$ , then $g(d) = 0$ , otherwise determine the first position, determine the elements in the first cycle section - determine the order of placement of each permutation, and Put that one element, so $g(d) = (d - 1) ! s ^ {d - 1}$ . At this time, divide and conquer FFT, or EGF, can be performed, $F = e ^ G$ .

May 8th

1. Multi-way merge: Given 10 sequences with a length of 100,000, select one item in each sequence, and the first 100,000 of the sums are smaller.

Consider merging two sequences at a time, taking the first 100,000 smaller ones. The first method is to sort the two sequences from small to large, then there are only O(n) decision objects each time, which can be expanded on a one-dimensional plane or a two-dimensional plane. The second approach, notice that ij <= n must be satisfied, so there are only O(n log n), take these things out and sort them.

You can consider doing K-dimensional directly, BFS directly on the K-dimensional hypergeometry, using the heap to maintain the optimal decision point, each time selecting an optimal object expansion, and then enumerating the surrounding points, if each dimension of it is closely spaced If it is connected, then adding it to the set of better decision points will be a little troublesome to implement.

"2017 Multi-University Training Contest 1": Given a cactus, find the spanning tree with the smallest top K. Get the dots on each ring of the cactus out, and then there's the question above.

2. "2017 Multi-University Training Contest 1": For each position i, given L[i] <= i <= R[i], ask how many permutations of 1 to n are there, satisfying for any i, a[i] = min(a[l], ..., a[r]) if and only if L[i] <= l <= i <= r <= R[i] .

That is to say, i is the smallest between L[i] and R[i], and is not satisfied for larger intervals.

For the whole, there must be a minimum position x, the minimum of L = 1, R = n. For other L, R, it must not pass the point x, so it will be divided into both sides of x, so only the two sides need to be recursively processed. If the left side is recursed first, and then the right side is recursed, the order of the intervals found each time is the order of increasing the left endpoint and decreasing the right endpoint.

Consider first to determine whether there is a solution. Then, double-keyword sorting is performed on the interval, and then a direct simulation is performed to determine whether the next interval satisfies the requirements L = l of the current divide and conquer, R = R of the current divide and conquer.

Considering the number of statistical schemes, each time the size of the left subtree is x and the size of the right subtree is y, then contribute $\binom{x + y}{x}$ .

3. Today, I am basically looking at the probability generating function, and I have not finished it yet.

May 9th

Learned a lot today.

1. Connected graph and general graph count

Let the property X on a graph, if each connected block satisfies the property X, then the whole graph satisfies the property X.

Let f(x) be the number of connected graphs with x points that satisfy the property, and g(x) be the number of graphs with x points that satisfy the property.

On the one hand, there are

$$g(x) = \sum_{i = 1} ^ x \binom{x - 1}{i - 1} f(i) g(x - i)$$

$$f(x) = g(x) - \sum_{i = 1} ^ {x - 1} \binom{x - 1}{i - 1} f(i) g(x - i)$$

On the other hand, let the EGF of f(x), g(x) be F(x), G(x), we have

$$F(x) = e ^ {G(x)}$$

$$ G (x) = \ ln F (x) $$

Use 1: Given the first aspect, you can use the divide-and-conquer FFT method, or you can convert it into the second aspect to find exp or ln .

Use 2: The problem of finding exp can be realized in O(n ^ 2) through this combined meaning.

2. Preprocessing the first type of Stirling number row, the first type of Stirling column, the second type of Stirling number row, the second type of Stirling column, the Bell number

Stirling numbers of the second kind:

(1) The second type of Stirling number line

According to the principle of tolerance and exclusion,

$${n \brace m} = \sum_{i = 0} ^ {m} (-1) ^ i \binom{m}{i} (m - i) ^ n$$

(2) Stirling column of the second type, OGF

$${n \brace m} = {n - 1 \brace m - 1} + m {n - 1 \brace m}$$

Let $F_m(x)$ be the OGF of $x \brace m$, then we have

$$F_m(x) = F_{m - 1}(x) x + F_m(x) m x$$

$$F_m(x) = \frac{x}{1 - m x} F_{m - 1}(X)$$

$$F_m(x) = x ^ m \prod_{i = 1} ^ m \frac{1}{1 - ix}$$

$F_m(x)$ can be solved using the technique of ln-exp.

(3) Another view of the second type of Stirling column, EGF, and the second type of Stirling row

Considering EGF, there is only one connected graph that satisfies the properties of $n$ points, so EGF is $e ^ x$ , so the EGF of the number of graphs with $n$ points and exactly $m$ connected blocks is

$$F_m(x) = \frac{(e ^ x - 1) ^ m}{m !}$$

Stirling numbers of the second kind that can be used to process a column.

This form can also deduce a row of the second kind of Stirling number, the principle is to directly perform the binomial expansion of the above generating function, and take the $n$ term:

$${n \brace m} = [x ^ n] \frac{(e ^ x - 1) ^ m}{m !} = [x ^ n] \frac{\sum_{i} \binom{m}{i} e ^ {ix} (-1) ^ {m - i}}{m !} = \frac{1}{m !} \sum_i \binom{m}{i} i ^ n (-1) ^ {m - i}$$

Stirling numbers of the first kind:

(1) The first type of Stirling line

According to the meaning of the combination, it can be deduced that

$$x ^ {\overline{n}} = \sum_{i} {n \brack i} x ^ i$$

There is another way to deduce the above formula, which is based on

$${n \brack m} = (n - 1) {n - 1 \brack m} + {n - 1 \brack m - 1}$$

Using OGF, there is

$$F_n(x) = (n - 1) F_{n - 1} (x) + F_{n - 1}(x) x = (x + n - 1) F_{n - 1} (x) = ... = x ^ {\overline{n}}$$

The first is a divide-and-conquer FFT, and the second is a multiply + FFT, which can be used to deal with a row of Stirling numbers of the second kind.

(2) The first type of Stirling column

Using EGF, the number of connected graphs satisfying the properties of $n$ points is $(n - 1) !$ , and EGF is

$$F(x) = \sum_i \frac{(i - 1) ! x ^ i}{i !} = \sum_i \frac{x ^ i}{i} = - \ln (1 - x)$$

So the EGF of the first kind of Stirling column is

$$G(x) = \frac{{- \ln (1 - x) - 1} ^ m}{m !}$$

Bell number:

Similar to the EGF approach of the second type of Stirling column, the EGF of the Bell number is obviously

$$ G (x) = e ^ {e ^ x - 1} $$

3. Stirling inversion

$$f(x) = \sum_i {x \brace i} g(i) \Leftrightarrow g(x) = \sum_i (-1) ^ {x - i} {x \brack i} f(i)$$

$$f(x) = \sum_i {x \brack i} g(i) \Leftrightarrow g(x) = \sum_i (-1) ^ {x - i} {x \brace i} f(i)$$

To prove it, it is probably to expand with several formulas to obtain two convolution formulas of the first type and the second type, and then the four relationships can be easily proved.

Stirling inversion can be used to solve the related problems of connected graphs. It can not only deal with the problems of connected graphs, but also the problems of 10 connected graphs. It can also define the size of the connected block as the number in the set $S$ is legal , through Stirling inversion, the tolerance and exclusion coefficient of the mystery can also be obtained.

For the problem of connectivity, we can roughly recall the count of connected graphs and general graphs, as well as Stirling inversion.

"Example" is a simple graph of 10 points, asking how many subsets of edges there are, and the graph is connected after satisfying the edges in the reserved subsets.

Consider a number of blocks, no edges are connected between the blocks, and the blocks are connected casually, and then the tolerance and exclusion coefficients are contributed and accumulated, and now the tolerance and exclusion coefficients are solved.

Suppose I have some scheme that is actually $x$ connected blocks, it should be computed $[x = 1]$ times, actually counted in all the more careful blocks, so

$$[x = 1] = \sum_i {i \brace x} f(i)$$

$$f(x) = (-1) ^ {x - 1} {x \brack 1} = (-1) ^ {x - 1} (x - 1) !$$

Besides, the "XOR graph" question on "BZOJ" also uses the same idea.

4. Some Counting Problems of Undirected Euler Graphs

"Problem 1" The number of graphs in which each connected block has an Euler circuit with n points labeled.

Consider building a spanning tree, a selection scheme for the edges outside the spanning tree, the tree edge can uniquely determine the selection scheme through the tree DP, so the answer is

$$cnt = 2 ^ {\binom{n}{2} - n + 1}$$

"Problem 2" The number of connected Euler graphs with n points with labels.

"Question 3" Given a graph, each point has parity $d_i$, ask how many edge retention methods are there so that the degree of each point meets the parity requirement.

If $\sum d$ in a connected block is an odd number, there is no solution; otherwise, let $C$ be the number of connected blocks, and the answer is

$$cnt = 2^{m - n + C}$$

"Problem 4" Given a graph, find how many subgraphs satisfy that each connected block has an Euler circuit edge.

"Problem 5" Given a graph, find the sum of the squares of the edges of the subgraphs whose edges each connected block has an Euler cycle.

"Question 6" The number of unlabeled graphs with 60 points.

Apply Burnside, enumerate all the permutations, and decompose them into several loop sections. There are $\left\{ \frac{s}{2} \right\}$ edges inside the loop section, and two loop sections $(s_1, s_2)$ edges, so the total number of solutions is

$$2 ^ {\sum \left\{ \frac{s_i}{2} \right\}} + \sum (s_i, s_j)$$

It is found that the answer is only related to the split scheme, so consider enumerating all splits and count how many permutations a split can correspond to. The number can be regarded as generating $n !$ permutations, and then deduplication, it should be Yes

$$\frac{n !}{ \prod_{\text{Every si, ci times}} s_i ^ {c_i} c_i ! }$$

 "Question 7" "Original" 60 points The number of graphs in which each connected block has an Euler circuit.

Enumerate each split.

For a loop of size s, consider the inner joins. If s is odd, then all joins have no effect; if s is even, joins with distance s / 2 will make the degree of each point The parity is XORed by one, and the others can be arbitrarily connected.

Considering the connection between two connected blocks, let the loop size be s1, s2, then there are (s1, s2) times, each point on the left connects s2 / (s1, s2) edges to the right, and each point on the right has s2 / (s1, s2) edges points to the left with s1 / (s1, s2) edges. If s2 / (s1, s2) and s1 / (s1, s2) are even numbers, then connect them at will. If there is an odd number, then there are (s1, s2) opportunities to XOR all points in A by one. If both are odd numbers, there are (s1, s2) chances to XOR all points in A and B by one, and we connect an edge between the two points, and the edge weight is (s1, s2).

At this point, it can be seen that the degree parity of all points in a loop is consistent, so each loop can be regarded as a large point for analysis, let d(x) be the number of opportunities that a large point x can XOR by one, which is

$$d(x) = \sum_{\text{odd, even} (s_x, s_?)} + [\text{s(x) is even}]$$

The problem becomes: each point can choose d(x) times of XOR chance, and the edge weight can be chosen between the two points of the edge and the chance of XOR one, ask how many options are there, so that each point 0 at the end.

Discuss each connected block. The single-point XOR of this connected block must be an even number, and when it is an even number, the edge selection scheme is $2 ^ {\sum_{odd, odd} (s_i, s_j)} - \ text{points} + 1$ . It is independent of the point selection scheme, so it is directly multiplied. Let $C = \sum d$ , then the XOR scheme of points is

$$ \ sum_ {2 | i} \ binomial {C} {i} = [C = 0] + [C \ ne 0] 2 ^ {C - 1} $$

The combined explanation is that for the first $C - 1$ options, the last one has a unique option corresponding to it. Algebraic proofs can be done by mathematical induction, or by unit complex roots and the binomial theorem.

In summary, the answer is

$$\text{answer} = \frac{1}{n !} \sum_{\text{Split} P \in \text{Split}(n)} \frac{n !}{ \prod_{\text {every si, ci times}} s_i ^ {c_i} c_i ! } 2 ^ {\sum \lfloor \frac{s_i}{2} \rfloor + \sum_{\text{even, even}} (s_i, s_j)} \prod_{\text{connected block}} 2 ^ {\sum_{odd, odd} (s_i, s_j) - \text{points} + 1} \times ([\sum d = 0] + [\ sum d \ne 0] 2 ^ {\sum d - 1})$$

 "Question 8" Counting Euler graphs connected by 10 points

Just apply another Stirling inversion to solve this problem, and the time complexity is n * sum (Bell(i) * The scheme of splitting n into i numbers).

This problem is not very good, because there is no guarantee of connectivity within a loop section.

Five, a convolution

$$C(x) = \sum_{i - j = x} A(i) B(j)$$

When doing it, it is equivalent to doing B in reverse, with a displacement of $n - 1$.

For example, some FFT problems caused by the principle of inclusion and exclusion, the most annoying thing to me is

$$g(x) = \sum_{i = x} ^ n (-1) ^ {i - x} \binom{i}{x} f(x)$$

6. Problems like tossing a coin, probability generating function, the first paper of the 2018 training team

(1) Let the probability generating function of discrete random variable X be

$$F(x) = \sum_{i} P(X = i) x ^ i$$

It can easily and briefly find the expectation and variance of a random variable X:

$$E(x) = \sum_i i P(x = i) = F'(1)$$

$$E(x ^ \underline{k}) = \sum_i i ^ {\underline{k}} P(x = i) = F ^ (k)(1)$$

$$Var(x) = E(X ^ 2) - E(X) ^ 2 = F''(1) + F'(1) - F'(1) ^ 2$$

(2) Five solutions to a topic in the Matrix67 book I thought of

Flip a coin and ask for the expected number of two heads in a row for the first time.

Definition of "Practice One" Expectations

$$answer = \sum_i i \frac{1}{4} f(i - 2)$$

$f(x)$ represents the probability of throwing the $x$th time, the $x$th time is down, and there has been no two upsides before, then

$$f(x) = \frac{1}{4} f(x - 2) + \frac{1}{2} f(x - 1)$$

Build OGF, with

$$F(x) = \frac{4}{1 - 2x - x ^ 2}$$

$$answer = \frac{1}{4} (F'(1) + 2F(1)) = 6$$

"Approach 2" Defining the Expected Abelian Summation Form

$$answer = \sum_{i \ge 0} P(X > i) = \sum_i \frac{1}{2} f(i - 1) + f(i) = \frac{3}{2} F'(1) = 6$$

"Approach 3" probability generating function

Let $f(i)$ represent the probability that $i$ times just end, $g(i)$ represent the probability that $i$ times do not end, and the corresponding OGFs are $F(x), G(x)$, then

$$F(x) + G(x) = 1 + x G(x)$$

$$G(x) \frac{x ^ 2}{4} = (\frac{x}{2} + 1) F(x)$$

Differentiate the first expression and substitute $x = 1$ , we have

$$F'(1) = G(1)$$

Bringing in $x = 1$ to the second equation, it is easy to get

$G(1) = 6$

"Approach 4" directly set the desired state

Let f(i) denote the expected number of times that i have now made i ups to two ups.

f(0) = 1 + 1 / 2 f(0) + 1 / 2 f(1)

f(1) = 1 + 1 / 2 f(0) + 1 / 2 f(2)

f(2) = 0

Solve the equation and the answer will come out.

The linear nature of "Approach 5" expectations

Let f(i) denote the expected number of times that the current i ups are reached to i+1 ups.

f(0) = 1 / (1 / 2) = 2

f(1) = 1 + 1 / 2 (f(0) + f(1)), f(1) = 4

So the answer is f(0) + f(1) = 6 .

(3) A topic during training in Beijing

Given a string S of character set m and length L, randomly generate a character at the end each time, ask how many occurrences of S are expected.

Let f(i) represent the probability that round i ends, and g(i) represent the probability that round i does not end. Similar to the one-column formula, the second formula considers adding a After S, the probability of the obtained state is calculated twice. On the one hand, it can be seen as $g_{cur - L} \frac{1}{m ^ L}$ , on the other hand, it can be seen as $\sum_i a_if( cur - (L - i)) \frac{1}{m ^ {L - i}}$

$$F(x) + G(x) = 1 + x G(x)$$

$$G(x) \frac{x ^ L}{m ^ L} = \sum_i a_i \frac{x ^ {L - i}}{m ^ {L - i}}$$

Taking the derivative of the first formula and substituting $x = 1$, and then substituting $x = 1$ for the second formula, I can get a simple conclusion that I was puzzled by at the time:

$$E(x) = \sum_i a_i m ^ i$$

(4) The problem of multiple strings

SDOI Coin Game

(5) An interesting probability problem: random $1$ to an even number $n$ each time, if $x$ is odd, then the counter is cleared, if $x$ is even, then the counter is incremented by one, and if $x = n$ , then stop, and find the expected value of the counter at the end.

As can be seen from this example, relations can be formulated by probability or expectation.

May 10

A classic conclusion

A sequence of length $n^2 + 1$ that differs in pairs of elements has either an ascending subsequence of length $n+1$ or a descending subsequence of length $n+1$.

Proof one:

The problem can be transformed into that the length of the descending subsequence of length $n$ is at most $n$, and it is proved that the sequence has an ascending subsequence of length $n+1$.

Seeing the subsequence, it is easy to think of the DP method, so we introduce such an auxiliary element: let $f(i)$ denote the length of the longest descending subsequence starting with $i$.

Then the direction of my thinking is to find the relationship between $f$ and the ascending subsequence, and I didn't find anything at first, so I directly try to observe the properties of $f$. How should I take all the longest descending subsequences of a position $x$ as the beginning? Then we must take $y > x, f[y] = f[x] - 1$ . Considering the relationship between several $y$, it is found that for $y_1 < y_2, f_{y_1} = f_{y_2}$, there must be $a_{y_1} < a_{y_2}$, otherwise $f_{y_1}$ can be updated by $f_{y_2}$. So the study of $x$ is also not needed.

For $y_1 < y_2 < ... < y_m$ with the same value of $f$, there must be $a_{y_1} < a_{y_2} < ... < a_{y_m}$. And notice that the value of $f$ is only $1, ..., n$, so according to the pigeonhole theorem, there must be a value of $f$ that satisfies $m \gen+1$, so the length of existence is $ Ascending subsequence of n+1$.

Proof two:

Using Dilworth's theorem directly, the longest descending subsequence can be regarded as the longest anti-chain, which is numerically equal to the minimum chain division, and the length of the longest ascending subsequence is at most $n$, so the chain division is at least $n+1$.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325213205&siteId=291194637