PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SRD0000082. Demen và những truy vấn lẻ (Demen and Odd Queries)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Demen và những truy vấn lẻ (Demen and Odd Queries)
Demen and Odd Queries
Source: VNOJ
Version: Phuoc Hung OJ Extended
Problem Statement
There are integer intervals on positions 1 through . Each query specifies pairwise distinct integer points. Count how many of the original intervals contain an odd number of these points, with endpoints included. Queries are independent.
Input
Read , then pairs , then . Each query consists of followed by exactly distinct points; there is no leading test-case count .
Output
Print the number of original intervals containing an odd number of query points.
Subtasks
- Subtask 1 (10 points): , , . ; , các đôi một khác nhau; ; .
- Subtask 2 (90 points): , , . ; , các đôi một khác nhau; ; .
Examples
Input
5
4 5
3 5
2 4
1 3
5 5
2
4 1 2 3 4
1 4
Output
3
3
Explanation
For points , the five intervals contain respectively 1,2,3,3,0 points, giving three odd counts. With the single point 4, exactly intervals , , and contain it.