[12.3] Diary

12.3 diary

Segment tree

Dyeing troubled for a long time ......

  1. Luo Gu P2161. Arrangements agreed issues.

Thinking : This question really should be balanced with the tree. But if it comes to a balanced tree, consider can not be directly applied set. Since there is but one feature, then you can take advantage of but one set of features to conflicting design overloaded operator <allowed equal, to carry out de-duplication. Since each element out only once, and therefore the complexity is correct.

Note : Operator overloading set to do it:

struct Date{
    int l,r;
    Date(int a=0,int b=0):l(a),r(b){}
    bool operator<(const Date &x)const{
        return r<x.l;
    }
};
set<Date> st;

Pay more const.

Staining solution watching.

  1. POJ2777, HDU5023. Segment tree coloring problem.

Function : interval + modify the query interval the number of different number. The fewer number of different colors.

Constructed : each color-shaped pressure. v [id] represents the current interval for all colors (like pressure). Maintenance interval values | values. Reducing the number of modifications to ensure a single logn with lazy.

Note : multiple sets of data to empty ah ......

  1. HDU1166. Single-point subtraction + summation interval.

Relatively simple, write soon.

  1. HDU1754. A single point of inquiry modify the maximum interval of +
  2. HDU1698. Sum + range interval modification.

Note that a is emptied, the other is a pushdown operation, is multiplied by the time interval length below. After the set or in accordance with chiefs of it, it does easier.

  1. OpenJ2299. The number of columns composed of n different number, ask how many reverse right.

Template : a one-dimensional partial order. Can merge, the tree can also be an array. First discrete, then back to front, the a [i] is set to 1, the section 1-i-1 and join to answer. Note that open LL!

to sum up

Today regarded as the trunk and on the line, but the basic things are doing very skilled, like addition and subtraction modify all figured out.

Tomorrow is monotonous data structure, lazy marking difficult version, CDQ divide and conquer.

Guess you like

Origin www.cnblogs.com/diorvh/p/11980564.html
Recommended