PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#PS0000128. Kiểm tra đoạn toàn hợp lệ (All Valid Range)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Kiểm tra đoạn toàn hợp lệ (All Valid Range)
All Valid Range
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given a binary array , call an entry valid if it equals 1 and invalid if it equals 0. For each inclusive interval , determine whether every entry in it is valid. The array does not change.
Input
The first line contains , the array length and query count.
The second line contains integers .
Each of the next lines contains integers .
Output
Print lines: YES if every entry in the queried interval equals 1, otherwise NO.
Subtasks
- Subtask 1 (30 points): ; ; for each query; for every .
- Subtask 2 (30 points): ; ; for each query; for every .
- Subtask 3 (40 points): ; ; for each query; for every .
Example 1
Input
4 2
1 1 0 1
1 2
2 4
Output
YES
NO
Explanation
Interval contains 1,1 and is valid. Interval contains 1,0,1, so position 3 makes it invalid.