Summary of some of the main points of NOIP

1. Dilworth's Theorem: In a sequence, the number of longest descending subsequences (minimum division of descending subsequences) is equal to the length of its longest non-descending subsequence.

2. The return values ​​of the three functions floor(), ceil(), and round() are all floating -point numbers . floor() rounds the floating-point number down, ceil() rounds the floating-point number up, and round( ) is to round the floating point number;

3.#define cin std::ios::sync_with_stdio(false); cin

   #define cout std::ios::sync_with_stdio(false); cout

   Cannot be used with scanf();

4. When taking modulo for subtraction, the modulo p should be added first and then modulo p should be added to control the range of the answer within the range of positive integers;

5. Transitive closure: Given several elements and several pairs of binary relationships, and the relationship is transitive, Floyd can be used to solve it;

6. In DP, the stage should be placed in the outermost loop;

7. For a directed graph (with negative weight edges), when finding the shortest path, you can use the framework of topological order to process the entire graph, and then run Dijkstra in the strongly connected components that do not contain negative weight edges;

8. For the minimum cycle problem of a directed graph, you can enumerate the starting point k and use dijkstra to run the shortest path. When k is taken out for the first time, let dis[k]=99999999; if k is taken out for the second time, dis[k] is the minimum ring length after k;

9. Let f[n] be the nth item of the Fibonacci sequence, then gcd(f[n],f[m])=f[gcd(n,m)]; ( the proof portal is here )

10. Let f[n] be the nth item of the Fibonacci sequence , then gcd(f[n],f[n+1])=1; ( the proof portal is here )

11. Convert a decimal number to binary:

inline void print(int x)
{
    stack<bool>st;
    while (x)st.push(x%2),x/=2;
    while (st.size())printf("%d",st.top()),st.pop();
    puts("");
}

12. Run dfs at any point in a tree to find the farthest point p, and then run dfs with p to find the farthest point q, then dis[p][q] is the diameter of the tree

13. When performing left shift and right shift operations, the type of the number being shifted should be consistent with the type of the answer. Such as: long long ans=(1<<n) is wrong, and long long ans=(1LL<<n) is right.

14. Cantor Expansion: A bijection of all permutations to a natural number . X = A[0] * (n-1)! + A[1] * (n-2)! + … + A[n-1] * 0! A[i] refers to the number after position i The number of values ​​less than A[i]. The calculated data expansion value is the value of - 1 in all permutations, so X + 1 is the order in all permutations.

15. When building bidirectional edges in a network flow, be sure to build forward and reverse edges together. Otherwise, it will die miserably when i (the sequence number of the edge)^1;

16. When the line segment tree is pushed down, be sure to update the sum value of k*2 and k*2+1 with the lazy value of k point, and pass the lazy directly; update sum, lazy at the end of the modification operation; note: lazy Indicates the impact on the next point, it does not affect this point;

17. Do not open long long to see ancestors;

18. When dividing into two, you cannot assign the initial value of l to 1, r=INT_MAX; because 1+INT_MAX explodes int! ! ! ! ! ! ! ! ! ! !

19. Characteristics of dfs order: In 2*n numbers, the closed interval l[u] to r[u] is the dfs order of the word tree with x as the root, so the subtree statistics can be converted into a sequence through the dfs order interval statistics on ;

20. If it passes through each edge once from s to t, the path is an Euler path from s to t ; if it passes through each edge once from s to s, the path is an Euler circuit ; there is an Euler circuit The graph is called Euler graph

21. Judgment of Euler graph: the graph is connected and the degree of all points is even; the judgment of the existence of Euler road: the graph is connected and the degree of exactly two points is odd, and the rest of the points are even;

22. For the edge weight only 0 and positive difference constraint system, you can use tarjan to shrink the points when running the longest path; if an SCC contains an edge with an edge weight greater than 0, then there must be no solution, otherwise you can normal tarjan shrinkage Click and run the DP on the topological order;

23.有向图的必经点和必经边:可以用NlogN的时间利用支配树求解,但若无环,就可以在原图和反图上跑两遍dp,求出S到x的路径数f[x]和x到T的路径数g[x];那么对于一个边(u,v),如果f[u]*g[v]=f[T],那么它就是桥。如果对于一个点u,f[u]*g[u]=f[T],那么它就是割点;

24.Konig定理:一张二分图,求出最小点集{S},使得图中任意一条边都至少有一个点属于S;这种问题称作最小点覆盖;而Konig指出:二分图的最小点覆盖所包含的点数等于二分图的最大匹配所包含的边数;

25.最小割等于最大流;最小割:将一些边删去后S和T不连通,且删去的边的容量之和最小;

26.在无向图中:桥一定是搜索树上的边,一个简单环上的边一定不是桥;

27.判断桥的方法:dfn[u]<dfn[v](需要考虑重边,所以记录的是父亲边);判断割点的方法:dfn[u]<=dfn[v](不需要考虑重边,所以不用记录);

28.点双连通图的判定:以下两个条件满足其一:1.图的顶点数不超过2;2.图的任意两点都同时包含在至少一个简单环中;

29.边双连通图的判定:任意一条边都包含在至少一个简单环中;

30.将一个图的所有桥删去后所得的若干连通块便是若干边双;

 ~不定期更新~

转载于:https://www.cnblogs.com/kamimxr/p/11526914.html

Guess you like

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