#BST0000013. Liệt kê khóa trong đoạn (Report BST Keys in a Range)
Liệt kê khóa trong đoạn (Report BST Keys in a Range)
Report BST Keys in a Range
Source: Phuoc Hung OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Build a BST from in insertion order. Duplicate keys are ignored.
Given integers and , if , select every stored key satisfying and print the selected keys in increasing order.
If , the requested range is considered empty and no key is selected.
Input
The first line contains .
If , the next line contains signed integers . If , this line is absent.
The last line contains and .
Output
If at least one key belongs to the closed interval , print those keys in increasing order, separated by one space.
If no key qualifies or , print EMPTY.
Subtasks
Subtask 1 (20 points): .
Subtask 2 (30 points): .
Subtask 3 (50 points): .
In all subtasks, are signed 64-bit integers. Duplicate insertion keys are ignored.
Examples
Input
7
8 3 10 1 6 14 4
4 10
Output
4 6 8 10
Explanation
The stored keys in the closed interval are . In increasing order they are exactly 4 6 8 10.