| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 12193 | Binary Search Tree Operation |
|
| 12666 | Hunter Likes Cypher |
|
Description
The problem will ask you to create a binary search tree, and there will be 4 kinds of commands to complete
1. P : please print out the binary search tree in in-order form in th line ,if the tree is empty, please print "NULL"(There is an whitespace between each number, also after the last number,no space after NULL)
2. GetMax : print out the maximum height of the binary search tree( There need no space after output number)
3. SumLevel (input) : print out the sum value of the nodes at the input level in the line, if the input level is bigger than the maximum height, please print out "0". ( There need no space after output number)
4. AverLevel (input) : print out the average value of the nodes at the input level in the line, please show only 3 digits after decimal point of the average numbers of level, if the input level is bigger than the maximum height, please print out "0". (You can simply use %.3f to display in such way) ( There need no space after output number)
the root level will represent as 1( for SumLevel & AverLevel, if the input level is 0, please print "0")
Input
The first line contains an integer N , which indicates the number of nodes of the binary search tree.
The second line is the data for create binary search tree
The third line contains an integer M , which indicates the number of commands.
Following line will be the input instruction
If there is same input value, please ignore the second one.
Output
There need to print newline in the end.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
"Bieh Ji Jhe Shuo Ni Ai Wo Dao Tian Chang Di Jiou ~~~"
Hunter likes to dance, and joined the nthu pop dance club.
One day he asked Jeff , Joshua , Bena , Ricky ... to form a circle to cypher, they used to spin a bottle to determine who is the next one.
But today they want to do it in another way, they count from 0th member M times, so the (M-1)th member solos, when he/she finishes, he/she will be removed from the circle, and count from mth person m times again...
Until every members have soloed.
Now Hunter wanna know the solo's order, can you help him?
Input
There will be multiple testcases in each input file, but no more than 10
Two integer N, M, in first line, N means the numbers of members in the circle.
And N integers Ai in the second line which means the index of ith member , 0 <= i < N , 0 <= Ai < N
1 <= N <= 5000
1 <= M <= 10000000
You should do it in fast way, or you will get time limits exceeded in last three testcases.
Output
Output the solo's order.