#C4979. Count Missing Pages
Count Missing Pages
Count Missing Pages
In this problem, you are given several test cases where each test case represents a set of torn-out page indications from a book. Each torn page entry is provided either as an individual page number or as a range in the format start-end
. Your task is to determine the total number of unique missing pages per test case.
For example, if you are given the entry 1-2
and 2-3
for a single test case, the actual missing pages are 1, 2, and 3, so the output should be 3.
Formally, for a given test case with an integer and a list of tokens (each token being either a single number or a range in the format start-end), compute the number of unique pages. All page numbers are positive integers.
inputFormat
The input is given from stdin and consists of multiple test cases.
The first line contains an integer , the number of test cases.
For each test case:
- The first line contains an integer $N$, the number of torn-out page entries.
- The second line contains $N$ space-separated tokens, each representing either a single page number or a range in the form
start-end
(with no extra spaces).
outputFormat
For each test case, output a single integer on a new line representing the total number of missing pages.## sample
1
3
1 4 6
3
</p>