13785 - Camo's Binary Search Tree   

Description

Once upon a time, Camo found that a binary search tree is a very powerful tool, so she wants to build it to support her job, could you help her?

 

There are two instructions below with the description:

 

 1. Insert num

Insert a number into the binary tree. If the number is already in the binary tree, skip it.

 

2. Print

Print the binary tree in pre-order

 

This is a partial judge problem, you're asked to implement these 2 functions.

 

Input

The input consists of multiple instructions (1 ≤ number of instructions ≤ 105)

 

the number of each instruction is a positive integer and not greater than 109.

 

Output

The output only consists of a line denoting the pre-order binary tree after every Print instruction.

 

 

It's guaranteed that for every Print instruction, the tree is not empty.

 

Sample Input  Download

Sample Output  Download

Partial Judge Code

13785.c

Partial Judge Header

13785.h

Tags




Discuss