《补题》(Codeforces Round #852 (Div. 2), problem: (B) Fedya and Array)

217 阅读1分钟

思维:构造符合题意的数列

构造 x x-1 x-2 ... y+1 y y+1 ... x-1

#include <bits/stdc++.h>

using i64 = long long;

void solve() {
	i64 x, y;
	std::cin >> x >> y;

	std::cout << (x - y) * 2 << "\n";
	for (int i = x; i >= y; i --) {
		std::cout << i << " ";
	}

	for (int i = y + 1; i <= x - 1; i ++) {
		std::cout << i << " ";
	}
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	int t;
	std::cin >> t;

	while (t --) {
		solve();
	}
	return 0;
}