PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#PS0000263. Kiểm tra độ phủ các số nguyên (Check if All the Integers in a Range Are Covered)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Kiểm tra độ phủ các số nguyên (Check if All the Integers in a Range Are Covered)

Check if All the Integers in a Range Are Covered

Source: LeetCode

Version: Phuoc Hung OJ Extended

Problem Statement

Given NN inclusive intervals [li,ri][l_i,r_i] and an inclusive target interval [L,R][L,R], determine whether every integer in the target belongs to at least one given interval.

Input

First line: N,L,RN,L,R. Next NN lines: li,ril_i,r_i.

Output

Print true if every target integer is covered; otherwise print false.

Subtasks

  • Subtask 1 (20 points): 1≤N≤51\le N\le 5; 1≤li≤ri≤501\le l_i\le r_i\le50; 1≤L≤R≤501\le L\le R\le50.
  • Subtask 2 (30 points): 1≤N≤501\le N\le 50; 1≤li≤ri≤501\le l_i\le r_i\le50; 1≤L≤R≤501\le L\le R\le50; L=RL=R.
  • Subtask 3 (50 points): 1≤N≤501\le N\le 50; 1≤li≤ri≤501\le l_i\le r_i\le50; 1≤L≤R≤501\le L\le R\le50.

Example 1

Input

3 2 5
1 2
3 4
5 6

Output

true

Explanation

2 belongs to the first interval, 3 and 4 to the second, and 5 to the third.

Example 2

Input

2 21 21
1 10
10 20

Output

false

Explanation

Neither interval contains 21.