PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CC0000037. Tìm điểm phía trên bên phải (Points)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tìm điểm phía trên bên phải (Points)
Points
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Maintain a changing set of points on the Cartesian plane. add x y adds an absent point ; remove x y erases a present point. For find x y, consider only points satisfying both and . Choose the point with minimum , breaking ties by minimum . If no point qualifies, output -1.
Input
The first line contains . Each of the next lines is add x y, remove x y, or find x y.
Output
For each find, print the chosen coordinates, or -1 if no point qualifies.
Subtasks
- Subtask 1 (20 points): ; ; each
addadds an absent point and eachremovedeletes a present point. - Subtask 2 (30 points): ; ; each
addadds an absent point and eachremovedeletes a present point. - Subtask 3 (50 points): ; ; each
addadds an absent point and eachremovedeletes a present point.
Examples
Input
7
add 1 1
add 3 4
find 0 0
remove 1 1
find 0 0
add 1 1
find 0 0
Output
1 1
3 4
1 1
Explanation
Point (1,1) is initially the leftmost valid point. After removing it, (3,4) is chosen; adding it back restores (1,1).