PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CC0000036. Quản lý các khoảng đã đánh dấu (Range Module)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Quản lý các khoảng đã đánh dấu (Range Module)
Range Module
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
Initially, no real number is tracked. You must process operations on half-open intervals , including but excluding . addRange l r starts tracking all real numbers in the interval. removeRange l r stops tracking them. queryRange l r asks whether every real number in that interval is currently tracked.
Input
The first line contains . Each of the next lines contains addRange, removeRange, or queryRange followed by .
Output
For each queryRange query, print true when the entire interval is covered, otherwise print false.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
6
addRange 10 20
removeRange 14 16
queryRange 10 14
queryRange 13 15
queryRange 16 17
queryRange 10 20
Output
true
false
true
false
Explanation
Removing [14,16) leaves [10,14) and [16,20). Hence queries [10,14) and [16,17) are true.