A11285 | Exam in MAC
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
The Master's Assistance Center has announced an entrance exam, which consists of the following.
The candidate is given a set $s$ of size $n$ and some strange integer $c$ . For this set, it is needed to calculate the number of pairs of integers $(x, y)$ such that $0 \leq x \leq y \leq c$ , $x + y$ is not contained in the set $s$ , and also $y - x$ is not contained in the set $s$ .
Your friend wants to enter the Center. Help him pass the exam!
The candidate is given a set $s$ of size $n$ and some strange integer $c$ . For this set, it is needed to calculate the number of pairs of integers $(x, y)$ such that $0 \leq x \leq y \leq c$ , $x + y$ is not contained in the set $s$ , and also $y - x$ is not contained in the set $s$ .
Your friend wants to enter the Center. Help him pass the exam!
输入格式
Each test consists of multiple test cases. The first line contains a single integer $t$ ( $1 \leq t \leq 2 \cdot 10^4$ ) — the number of test cases. The description of the test cases follows.
The first line of each test case contains two integers $n$ and $c$ ( $1 \leq n \leq 3 \cdot 10^5$ , $1 \leq c \leq 10^9$ ) — the size of the set and the strange integer.
The second line of each test case contains $n$ integers $s_1, s_2, \ldots, s_{n}$ ( $0 \leq s_1 < s_2 < \ldots < s_{n} \leq c$ ) — the elements of the set $s$ .
It is guaranteed that the sum of $n$ over all test cases does not exceed $3 \cdot 10^5$ .
The first line of each test case contains two integers $n$ and $c$ ( $1 \leq n \leq 3 \cdot 10^5$ , $1 \leq c \leq 10^9$ ) — the size of the set and the strange integer.
The second line of each test case contains $n$ integers $s_1, s_2, \ldots, s_{n}$ ( $0 \leq s_1 < s_2 < \ldots < s_{n} \leq c$ ) — the elements of the set $s$ .
It is guaranteed that the sum of $n$ over all test cases does not exceed $3 \cdot 10^5$ .
输出格式
For each test case, output a single integer — the number of suitable pairs of integers.
输入输出样例
输入 #1
8 3 3 1 2 3 1 179 57 4 6 0 3 5 6 1 1 1 5 10 0 2 4 8 10 5 10 1 3 5 7 9 4 10 2 4 6 7 3 1000000000 228 1337 998244353
输出 #1
3 16139 10 2 33 36 35 499999998999122959
In the first test case, the following pairs are suitable: $(0, 0)$ , $(2, 2)$ , $(3, 3)$ .
In the third test case, the following pairs are suitable: $(0, 1)$ , $(0, 2)$ , $(0, 4)$ , $(1, 3)$ , $(2, 6)$ , $(3, 4)$ , $(3, 5)$ , $(4, 5)$ , $(4, 6)$ , $(5, 6)$ .
In the third test case, the following pairs are suitable: $(0, 1)$ , $(0, 2)$ , $(0, 4)$ , $(1, 3)$ , $(2, 6)$ , $(3, 4)$ , $(3, 5)$ , $(4, 5)$ , $(4, 6)$ , $(5, 6)$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted