题目大意:给出两个数x,y求一个所有相邻元素都差1的数组,使得所有局部最小值(三个连续数中的最小值)的和等于y,所有局部最大值的和等于x
-1e9<=y<x<=1e9
思路:因为x,y为局部最值的和,那不妨令x和y分别为整个数组的最大值和最小值,那么只需在他们中间补充连续的x-y-1个数即可,构造出的数组长度即为(x-y-1)*2+2=2*(x-y),例如对于x=3,y=-2,构造出的数组就可以是-2,-1,0,1,2,3,2,1,0,-1
//#include<__msvc_all_public_headers.hpp>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
int main()
{
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
int t;
cin >> t;
while (t--)
{
int x, y;
cin >> x >> y;
int len = x - y;
cout << 2 * len << endl;
for (int i = y + 1; i <= x; i++)
{//从最小值到最大值
cout << i << " ";
}
for (int i = x - 1; i >= y; i--)
{//从最大值到最小值
cout << i << " ";
}
cout << endl;
}
return 0;
}