Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- constexpr auto sp = " ";
- constexpr auto en = "\n";
- using ull = unsigned long long;
- using ll = long long;
- using ld = long double;
- #define isz(x) int((x).size())
- #define all(x) begin(x), end(x)
- #define rall(x) rbegin(x), rend(x)
- #define fin(x) for (auto& it : x) cin >> it;
- #define foutsp(x) for (auto& it : x) cout << it << " "; cout << en;
- #define fouten(x) for (auto& it : x) cout << it << en;
- #define fyesno(x) cout << (x ? "YES" : "NO") << en;
- using namespace std;
- void solve();
- void global();
- ull get_gcd(ull a, ull b) {
- return b == 0 ? a : gcd(b, a % b);
- }
- ull get_lcm(ull a, ull b) {
- return a * b / gcd(a, b);
- }
- vector<int> to_z(string& s, bool flag = false) {
- vector<int> z(isz(s));
- if (flag) z[0] = isz(z);
- int l = 0, r = 1;
- for (int i = 1; i < isz(z); i++) {
- if (r > i) z[i] = min(z[i - l], r - i);
- while (z[i] + i < isz(z) && s[z[i]] == s[z[i] + i]) z[i]++;
- if (r < z[i] + i) { l = i; r = z[i] + i; }
- }
- return z;
- }
- ull get_c(ull n, ull k) {
- ull r = 1, dif = n - k;
- for (int i = 1; i <= k; i++)
- r += r * dif / i;
- return r;
- }
- string get_bits(ull x) {
- string r = "";
- while (x != 0) {
- if (x & 1) r.push_back('1');
- else r.push_back('0');
- x >>= 1;
- }
- reverse(all(r));
- return r;
- }
- string pi_str = "31415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679";
- string alphabet_str = "abcdefghijklmnopqrstuvwxyz";
- double get_pi() {
- return acos(-1);
- }
- int my_rand(int left, int right) {
- return rand() % (right - left + 1) + left;
- }
- void test() {
- solve();
- }
- void tests() {
- int t; cin >> t;
- for (int i = 1; i <= t; i++) {
- solve();
- }
- }
- int main() {
- ios::sync_with_stdio(false);
- cin.tie(nullptr); cout.tie(nullptr);
- cout.setf(ios::fixed); cout.precision(12);
- srand(time(0));
- global();
- tests();
- return 0;
- }
- void global() {
- }
- void solve() {
- int n;
- ull k;
- cin >> n >> k;
- if (k & 1) {
- cout << "No" << en;
- return;
- }
- vector<int> v(n);
- for (int i = 0; i < n; i++)
- v[i] = n - i;
- ull sum = 0;
- for (int i = 0; i < n; i++)
- sum += abs(v[i] - (i + 1));
- if (sum < k) {
- cout << "No" << en;
- return;
- }
- vector<int> answer(n);
- for (int i = 0; i < n; i++)
- answer[i] = i + 1;
- if (k == 0) {
- cout << "Yes" << en;
- foutsp(answer);
- return;
- }
- ull k_ = 0;
- for (int i = 0; i < n; i++) {
- int j1 = i, j2 = n - i - 1;
- int x = 2 * (j2 - j1);
- if (k_ + x < k) {
- k_ += x;
- swap(answer[j1], answer[j2]);
- }
- else if (k_ + x == k) {
- swap(answer[j1], answer[j2]);
- cout << "Yes" << en;
- foutsp(answer);
- return;
- }
- else {
- int x = k - k_;
- int j1 = i, j2 = i + x / 2;
- swap(answer[j1], answer[j2]);
- cout << "Yes" << en;
- foutsp(answer);
- return;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement