数据结构与算法习题 loser tree(败方树)
Time Limit: 1000ms Memory Limit: 65536kB
Description
Given an interger array,you are required toconstruct a loser tree for it(compare twoadjacent array elements, and the comparison starts from the first element). Several modifications are made to the elements of the array. You arerequired to output the interger that every internal node represents for theloser trees that you constructed at first and got after every modification(theintergers are output according to the position of the internal node, from top tobottom,from left to right)
Input
The first line is the size of the array n and the number of modifications m.
The second line contains n intergers, they are elements of the array.
The next m lines represents the m modifications, every modification change the value of one element, each line contains two intergers, the first one is the index of the element modified,and the second is the value modified to.
Output
The output contains m+1 lines.
The first line is output of the interger that every internal node represents for the loser tree that you constructed at first(the intergers are output according to the position of the internal node, from top to bottom,from left to right)
The next m lines is ouput of the interger that every internal node represents for the loser tree constructed after the m modifications(the intergers are output according to the position of the internal node, from top to bottom,from left to right)
Sample Input
8 1