Sign in
or
Register
Courses
Textbook
Compiler
Contests
Topics
Courses
Data structures
cartesian tree
Module:
cartesian tree
Problem
1
/3
Binary search tree 1
Theory
Click to read/hide
Error
Problem
Implement a balanced binary search tree.
WARNING
! Using vector and set from the STL is STRICTLY PROHIBITED, however it is recommended to stress your solution with them to find bugs.
Input format:
The first line contains a number n - the number of tree operations. 1 <= n <= 100000.
Then n lines are given – tree operations. Each line contains one of the following operations:
1)
insert x – add the key x to the tree. If the key x is already in the tree, then nothing needs to be done.
2)
delete x – remove the key x from the tree. If the x key is not in the tree, then nothing needs to be done.
3)
exists x – if the key x is in the tree, then print “true”, otherwise “false”.
Output format:
Output sequentially the result of all operations exists. Each answer should be displayed on a separate line.
Example:
Enter
Output
6
insert 2
insert 5
insert 3
exists 3
exists 4
delete 5
true
false
(c) Kurbatov E., 2016
1000
ms
256 Mb
Rules for program design and list of errors in automatic problem checking
Teacher commentary