Toj 4146 seq Difficulty factor (1-5): 2
For action 0: use Add[v][x] to represent the sum of add added for I%b[v]=x a[i].
After all operations have been read for A[i], A[i]+=∑add[v][i%b[v]] \sum Add[v][i\%b[v]]
For Operation 1: We know that the number of x*b[v] to X*b[v]+b[b]-1 is added, so you can use a data structure to maintain a number for a range of numbers.
4147 Strange Network difficulty factor (1-5): 4
KD tree + minimum Spanning tree
4148 number 0 Difficulty factor (1-5): 2
There are a lot of ways to do this,
Method 1: Use an array of a[9] to simulate addition 1 to 108 1 to 10^8
A[0]-A[9] Represents a number of each bit, for the input of the inquiry from small to large sort, with a number of records 1 to the current number appeared a few 0, analog addition to I, the answer to the question I. To do +1, judge the current number 0, with a variable to record the number of 0.
Method 2: For n if can calculate the same as N and no more than n number of the number of occurrences 0, then the n is divided into 1−9,10−99....,10x−n 1-9,10-99....,10^x-nx is the number of n, respectively, the number of the calculation can be 0.
A method for calculating the number of 0 in a 10^x-n, for example: n = 999
Calculate 990,991 First, ... 999 appeared in a few 0
Then 90*,91*,92* ... 98*,* indicates that any number can appear, then you can split the numbers into 3 segments.
N1=9,k=0-8,x=*,x is any combination of 0-9, so n1,k appears 0 times multiplied by the number of x is the number of 0 occurrences, plus the number of 0 appearing in X can be,
4149 WordCount Difficulty Factor (1-5): 3
AC automata, suffix array
AC Automaton 1: Ignore the size of the alphabet, use the hash method to find the X child of a node u, x is the first X letter. The establishment of the Automata is O (n), because the hash design will create a conflict, the final complexity is O (CN)
AC Automaton 2: The alphabet is re-encoded, and a character is added to denote the end of the letter for the letter, such as 1111, with the letter 1111*, then the alphabet of the automaton is only 11 characters, re-encoding the equivalent of a word into a string shape such as: x1∗x2∗.....xn∗x_1 *x_2*.....x_n*, you can do it with a template. O (11n*logn)
Suffix array: also adds an end identifier O (NLOGN)
4150 Wordrank Difficulty Factor (1-5): 1
String sorting, you can map the string to a long long number, and then sort,
can also be ordered directly, but to avoid the assignment of the character array when sorting, the complexity of NLOGN can be too
4151 eat difficulty factor (1-5): 4
Tree Chain Split
4152 Tetris of Llin difficulty factor (1-5): 3
DP or sub-rule because the problem is too long, not many people to see, in fact, a medium problem
4153 I like graph difficulty factor (1-5): 2
The longest ascending subsequence, you can make it if you want to.
4154 TAC Difficulty Factor (1-5): 1
Determine if the triangle is within the circle, and use each point to determine if it is within the circle