Link
Magicianproblem Descriptionfantasy Magicians usually gain their ability through one of the three usual methods:possessing it As an innate talent, gaining it through study and practice, or receiving it from another being, often a god, spirit, or de Mon of some sort. Some Wizards is depicted as have a special gift which sets them apart from the vast majority of characters in fantasy W Orlds who is unable to learn magic. Magicians, sorcerers, wizards, Magi, and practitioners of magic by other titles has appeared in myths, folktales, and lit Erature throughout recorded, with fantasy works drawing from this background.
In medieval chivalric romance, the wizard often appears as a wise old man and acts as a mentor, with Merlin from the King Arthur stories representing a prime example. Other magicians can appear as villains, hostile to the hero.
Mr Zstu is a magician, he had many elves like Dobby, and each of the which has a magic power (maybe negative). One day, Mr. Zstu want to test his ability of doing some magic. He made the Elves stand in a straight line, from position 1 to position n, and he used both kinds of magic, change magic an D Query Magic, the first is to change an elf's power, the second is get the maximum sum of beautiful subsequence of a give N interval. A beautiful subsequence is a subsequence then all the adjacent pairs of elves in the sequence has a different parity of P Osition. Can do the same thing as Mr Zstu?
Inputthe first line was an integer T represent the number of test cases.
Each of the test case begins with a integers n, m represent the number of elves and the number of the time that Mr. Zstu use D his magic.
(N,m <= 100000)
The next line have n integers represent elves ' magic power, magic Power is between-1000000000 and 1000000000.
followed M lines, each of the line have three integers like
Type a B describe a magic.
If type equals 0, you should output the maximum sum of beautiful subsequence of interval [a, b]. (1 <= a <= b <= N)
If type equals 1, you should the magic power of the elf in position A to B. (1 <= a <= n, 1 <= b <= 1e9)
Outputfor each 0 type query, output the corresponding answer.
Sample Input1 1 1 1 0 1 1
Sample OUTPUT1
Source2015 multi-university Training Contest 3 Test instructions: Given n-long sequence. Action 1: Modify the value of a point. Operation 2: The maximum and of the sub-sequences of subscript parity in the interval [l,r] are obtained. What is subscript parity interleaved: sequence: 2 1 5 6 ask interval [1,4] then [1,4] all the next odd-even interleaved sub-sequence is {2},{1},{5},{6}{2,1} {1,5} {5,6} {2,6}{2,1,5} Therefore the maximum and for the 2+1+5+6 thought: line segment tree, for an interval maintains the maximum and of the sequence of odd (even) numbers beginning odd (even) number endings. Write and write just fine. Code
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
HDU 5316 Magician Segment Tree