#PS0000110. Truy vấn tổng lẻ (Odd Queries)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Truy vấn tổng lẻ (Odd Queries)
Odd Queries
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given an array , a query hypothetically sets every element at positions through to . Determine whether the resulting whole-array sum is odd. Every query starts from the original array; no query modifies subsequent queries.
Input
The first line contains integers .
The second line contains integers .
Each of the following lines contains three integers .
Output
Print lines, each containing YES for an odd resulting sum or NO otherwise. Letter case is ignored.
Subtasks
- Subtask 1 (20 points): ; ; ; ; .
- Subtask 2 (30 points): ; ; ; ; ; .
- Subtask 3 (50 points): ; ; ; ; .
Examples 1
Input
5 5
2 2 1 3 2
2 3 3
2 3 4
1 5 5
1 4 9
2 4 3
Output
YES
YES
YES
NO
YES
Explanation
The original total is 10. The five independent replacements produce , , , and . Their totals are . Only 38 is even, giving NO on line four and YES elsewhere.
Examples 2
Input
10 5
1 1 1 1 1 1 1 1 1 1
3 8 13
2 5 10
3 8 10
1 10 2
1 9 100
Output
NO
NO
NO
NO
YES
Explanation
The original total is 10. Replacement lengths are 6, 4, 6, 10, 9. The new sums are 82, 46, 64, 20, 901. Only the last sum is odd.