QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#365260#8107. PermutationckisekiAC ✓162ms251672kbC++204.2kb2024-03-24 22:58:112024-03-24 22:58:11

Judging History

你现在查看的是最新测评结果

  • [2024-03-24 22:58:11]
  • 评测
  • 测评结果:AC
  • 用时:162ms
  • 内存:251672kb
  • [2024-03-24 22:58:11]
  • 提交

answer

#include <bits/extc++.h>
#include <bits/stdc++.h>
using namespace std;

template <typename T>
using ordered_set =
    __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag,
                     __gnu_pbds::tree_order_statistics_node_update>;

#define all(x) begin(x), end(x)
#ifdef CKISEKI
#define safe cerr << __PRETTY_FUNCTION__ << " line " << __LINE__ << " safe\n"
#define debug(a...) debug_(#a, a)
#define orange(a...) orange_(#a, a)
void debug_(auto s, auto... a) {
  cerr << "\e[1;32m(" << s << ") = (";
  int f = 0;
  (..., (cerr << (f++ ? ", " : "") << a));
  cerr << ")\e[0m\n";
}
#include <experimental/iterator>
void orange_(auto s, auto L, auto R) {
  cerr << "\e[1;33m[ " << s << " ] = [ ";
  using namespace experimental;
  copy(L, R, make_ostream_joiner(cerr, ", "));
  cerr << " ]\e[0m\n";
}
#else
#define safe ((void)0)
#define debug(...) safe

#define orange(...) safe
#endif

constexpr int N = 250'000 + 1;
constexpr int L = 40;

constexpr int64_t INF = 1LL << 60;

int64_t dp1[L][L * (L - 1) / 2];
int64_t dp2[N][L];

int64_t add(int64_t a, int64_t b) { return min(a + b, INF); }

int64_t sub(int64_t a, int64_t b) {
  if (a == INF)
    return INF;
  return a - b;
}

int ans[N];

__int128 dp1s[L][L * (L - 1) / 2];
__int128 dp2s[N][L];

int64_t calc(int len, int64_t inv) {
  const int64_t max_inv = int64_t(len) * (len - 1) / 2;
  if (0 > inv or inv > max_inv)
    return 0;
  if (len < L) {
    return dp1[len][inv];
  }
  if (max_inv - L >= inv and inv >= L)
    return INF;
  if (inv >= L)
    return dp2[len][max_inv - inv];
  return dp2[len][inv];
}

__int128 MyGo(int len, int64_t inv, int l) {
  const int64_t max_inv = int64_t(len) * (len - 1) / 2;
  // calc(len, inv - l) + ... + calc(len, inv)
  const int64_t lb = max<int64_t>(inv - l + 1, 0);
  const int64_t rb = min<int64_t>(inv, max_inv);
  if (lb > rb)
    return 0;
  if (len < L) {
    if (lb)
      return dp1s[len][rb] - dp1s[len][lb - 1];
    return dp1s[len][rb];
  } else {
    if (lb >= max_inv - L) {
      return MyGo(len, max_inv - inv + l - 1, l);
    } else if (rb <= L) {
      if (lb)
        return dp2s[len][rb] - dp2s[len][lb - 1];
      return dp2s[len][rb];
    } else {
      return INF;
    }
  }
}

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);

  dp1[0][0] = 1;
  for (int i = 1; i < L; ++i) {
    const int inv = (i - 2) * (i - 1) / 2;
    for (int j = 0; j <= inv; ++j) {
      for (int k = 0; k <= i - 1; ++k) {
        dp1[i][j + k] = add(dp1[i][j + k], dp1[i - 1][j]);
      }
    }
  }
  dp2[0][0] = 1;
  for (int i = 1; i < N; ++i) {
    const int64_t inv = min<int64_t>(L - 1, int64_t(i - 1) * i / 2);
    int64_t sm = 0;
    for (int j = 0; j <= inv; ++j) {
      if ((j - (i - 1) - 1) >= 0)
        sm = sub(sm, dp2[i - 1][j - (i - 1) - 1]);
      sm = add(sm, dp2[i - 1][j]);
      dp2[i][j] = sm;
      // dp2[i][j] = dp2[i - 1][j - (i - 1)] + ... + dp2[i - 1][j]
    }
  }

  for (int i = 0; i < L; ++i) {
    const int inv = (i - 1) * i / 2;
    for (int j = 0; j <= inv; ++j) {
      dp1s[i][j] = dp1[i][j];
      if (j)
        dp1s[i][j] += dp1s[i][j - 1];
    }
  }
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < L; ++j) {
      dp2s[i][j] = dp2[i][j];
      if (j)
        dp2s[i][j] += dp2s[i][j - 1];
    }
  }

  int n;
  int64_t k;
  cin >> n >> k;

  if (n % 4 == 3 or n % 4 == 2) {
    cout << "NO\n";
    return 0;
  }

  int64_t inv = int64_t(n) * (n - 1) / 4;

  ordered_set<int> exists;
  for (int i = 1; i <= n; ++i)
    exists.insert(i);

  for (int i = 0; i < n; ++i) {
    int l = 0, r = int(exists.size()) + 1;
    while (r - l > 1) {
      int m = (l + r) >> 1;
      if (MyGo(n - i - 1, inv, m) < k)
        l = m;
      else
        r = m;
    }
    if (l == int(exists.size())) {
      cout << "NO\n";
      return 0;
    }
    k -= MyGo(n - i - 1, inv, l);
    inv -= l;
    ans[i] = *exists.find_by_order(l);
    exists.erase(exists.find_by_order(l));
  }
  assert(k == 1);
  assert(inv == 0);
  cout << "YES\n";
  for (int i = 0; i < n; ++i)
    cout << ans[i] << " \n"[i + 1 == n];
  return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 24ms
memory: 239696kb

input:

4 3

output:

YES
2 4 1 3

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 11ms
memory: 239604kb

input:

4 57

output:

NO

result:

ok single line: 'NO'

Test #3:

score: 0
Accepted
time: 28ms
memory: 239696kb

input:

1 1

output:

YES
1

result:

ok 2 lines

Test #4:

score: 0
Accepted
time: 24ms
memory: 239704kb

input:

1 2

output:

NO

result:

ok single line: 'NO'

Test #5:

score: 0
Accepted
time: 15ms
memory: 239704kb

input:

1 42

output:

NO

result:

ok single line: 'NO'

Test #6:

score: 0
Accepted
time: 29ms
memory: 239640kb

input:

4 1

output:

YES
1 4 3 2

result:

ok 2 lines

Test #7:

score: 0
Accepted
time: 27ms
memory: 239740kb

input:

4 6

output:

YES
4 1 2 3

result:

ok 2 lines

Test #8:

score: 0
Accepted
time: 16ms
memory: 239640kb

input:

4 7

output:

NO

result:

ok single line: 'NO'

Test #9:

score: 0
Accepted
time: 39ms
memory: 239644kb

input:

5 13

output:

YES
3 4 2 1 5

result:

ok 2 lines

Test #10:

score: 0
Accepted
time: 27ms
memory: 239936kb

input:

5 21

output:

YES
5 1 3 2 4

result:

ok 2 lines

Test #11:

score: 0
Accepted
time: 45ms
memory: 239704kb

input:

5 22

output:

YES
5 2 1 3 4

result:

ok 2 lines

Test #12:

score: 0
Accepted
time: 15ms
memory: 239656kb

input:

5 23

output:

NO

result:

ok single line: 'NO'

Test #13:

score: 0
Accepted
time: 41ms
memory: 239736kb

input:

8 3836

output:

YES
8 7 2 1 3 4 5 6

result:

ok 2 lines

Test #14:

score: 0
Accepted
time: 23ms
memory: 239860kb

input:

8 3837

output:

NO

result:

ok single line: 'NO'

Test #15:

score: 0
Accepted
time: 24ms
memory: 239736kb

input:

9 29228

output:

YES
9 8 4 1 2 3 5 6 7

result:

ok 2 lines

Test #16:

score: 0
Accepted
time: 27ms
memory: 239932kb

input:

9 29229

output:

NO

result:

ok single line: 'NO'

Test #17:

score: 0
Accepted
time: 27ms
memory: 239928kb

input:

9 32768

output:

NO

result:

ok single line: 'NO'

Test #18:

score: 0
Accepted
time: 34ms
memory: 239932kb

input:

2 1

output:

NO

result:

ok single line: 'NO'

Test #19:

score: 0
Accepted
time: 20ms
memory: 239668kb

input:

7 1

output:

NO

result:

ok single line: 'NO'

Test #20:

score: 0
Accepted
time: 15ms
memory: 239636kb

input:

13 296643390

output:

YES
13 12 11 7 1 2 3 4 5 6 8 9 10

result:

ok 2 lines

Test #21:

score: 0
Accepted
time: 37ms
memory: 239708kb

input:

13 296643391

output:

NO

result:

ok single line: 'NO'

Test #22:

score: 0
Accepted
time: 35ms
memory: 239636kb

input:

20 62119523114983223

output:

YES
20 19 18 17 16 10 2 1 3 4 5 6 7 8 9 11 12 13 14 15

result:

ok 2 lines

Test #23:

score: 0
Accepted
time: 19ms
memory: 239900kb

input:

20 62119523114983224

output:

YES
20 19 18 17 16 11 1 2 3 4 5 6 7 8 9 10 12 13 14 15

result:

ok 2 lines

Test #24:

score: 0
Accepted
time: 28ms
memory: 239636kb

input:

20 62119523114983225

output:

NO

result:

ok single line: 'NO'

Test #25:

score: 0
Accepted
time: 7ms
memory: 239640kb

input:

21 1

output:

YES
1 2 3 4 5 6 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7

result:

ok 2 lines

Test #26:

score: 0
Accepted
time: 16ms
memory: 239584kb

input:

21 1000000000000000000

output:

YES
17 21 14 6 9 4 3 11 7 2 20 1 18 15 12 16 5 10 8 13 19

result:

ok 2 lines

Test #27:

score: 0
Accepted
time: 27ms
memory: 239728kb

input:

44 333333333333333333

output:

YES
1 2 3 4 5 6 7 8 9 10 11 21 42 44 41 40 43 38 39 35 34 37 36 32 31 33 29 27 28 25 30 26 23 24 15 22 18 16 20 19 17 12 13 14

result:

ok 2 lines

Test #28:

score: 0
Accepted
time: 24ms
memory: 239672kb

input:

49 600000000000000000

output:

YES
1 2 3 4 5 6 7 8 9 10 11 12 13 37 47 49 44 46 45 48 43 42 41 39 40 35 38 33 31 36 34 30 27 32 25 28 29 26 24 23 17 22 20 19 21 18 16 15 14

result:

ok 2 lines

Test #29:

score: 0
Accepted
time: 31ms
memory: 239640kb

input:

16 738680521142

output:

YES
16 15 14 13 7 1 2 3 4 5 6 8 9 10 11 12

result:

ok 2 lines

Test #30:

score: 0
Accepted
time: 15ms
memory: 239696kb

input:

16 738680521143

output:

NO

result:

ok single line: 'NO'

Test #31:

score: 0
Accepted
time: 24ms
memory: 239644kb

input:

350 702274833889168257

output:

NO

result:

ok single line: 'NO'

Test #32:

score: 0
Accepted
time: 11ms
memory: 239708kb

input:

347 823694565238057857

output:

NO

result:

ok single line: 'NO'

Test #33:

score: 0
Accepted
time: 28ms
memory: 239720kb

input:

348 548514836018174081

output:

YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok 2 lines

Test #34:

score: 0
Accepted
time: 31ms
memory: 239664kb

input:

349 1000000000000000000

output:

YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok 2 lines

Test #35:

score: 0
Accepted
time: 16ms
memory: 239648kb

input:

17 11501573822788

output:

YES
17 16 15 14 11 1 2 3 4 5 6 7 8 9 10 12 13

result:

ok 2 lines

Test #36:

score: 0
Accepted
time: 23ms
memory: 239664kb

input:

17 11501573822789

output:

NO

result:

ok single line: 'NO'

Test #37:

score: 0
Accepted
time: 16ms
memory: 239800kb

input:

1536 1000000000000000000

output:

YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok 2 lines

Test #38:

score: 0
Accepted
time: 36ms
memory: 239664kb

input:

1533 1

output:

YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok 2 lines

Test #39:

score: 0
Accepted
time: 3ms
memory: 239696kb

input:

1534 639944301316494081

output:

NO

result:

ok single line: 'NO'

Test #40:

score: 0
Accepted
time: 15ms
memory: 239636kb

input:

1535 133749702370803553

output:

NO

result:

ok single line: 'NO'

Test #41:

score: 0
Accepted
time: 11ms
memory: 239648kb

input:

12 25598186

output:

YES
12 11 10 4 1 2 3 5 6 7 8 9

result:

ok 2 lines

Test #42:

score: 0
Accepted
time: 11ms
memory: 239648kb

input:

12 25598187

output:

NO

result:

ok single line: 'NO'

Test #43:

score: 0
Accepted
time: 32ms
memory: 239908kb

input:

5000 1

output:

YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok 2 lines

Test #44:

score: 0
Accepted
time: 12ms
memory: 240100kb

input:

4997 577621398254762881

output:

YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok 2 lines

Test #45:

score: 0
Accepted
time: 31ms
memory: 239936kb

input:

4998 1000000000000000000

output:

NO

result:

ok single line: 'NO'

Test #46:

score: 0
Accepted
time: 33ms
memory: 239928kb

input:

4999 1000000000000000000

output:

NO

result:

ok single line: 'NO'

Test #47:

score: 0
Accepted
time: 35ms
memory: 239936kb

input:

8 3836

output:

YES
8 7 2 1 3 4 5 6

result:

ok 2 lines

Test #48:

score: 0
Accepted
time: 33ms
memory: 239892kb

input:

8 3837

output:

NO

result:

ok single line: 'NO'

Test #49:

score: 0
Accepted
time: 23ms
memory: 241072kb

input:

30000 15298495309447071

output:

YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok 2 lines

Test #50:

score: 0
Accepted
time: 32ms
memory: 241040kb

input:

29997 253859976519879617

output:

YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok 2 lines

Test #51:

score: 0
Accepted
time: 31ms
memory: 239588kb

input:

29998 1

output:

NO

result:

ok single line: 'NO'

Test #52:

score: 0
Accepted
time: 33ms
memory: 239588kb

input:

29999 1000000000000000000

output:

NO

result:

ok single line: 'NO'

Test #53:

score: 0
Accepted
time: 11ms
memory: 239672kb

input:

5 10

output:

YES
3 2 4 5 1

result:

ok 2 lines

Test #54:

score: 0
Accepted
time: 15ms
memory: 239636kb

input:

5 25

output:

NO

result:

ok single line: 'NO'

Test #55:

score: 0
Accepted
time: 65ms
memory: 243220kb

input:

75000 1000000000000000000

output:

YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok 2 lines

Test #56:

score: 0
Accepted
time: 53ms
memory: 243448kb

input:

74997 1

output:

YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok 2 lines

Test #57:

score: 0
Accepted
time: 24ms
memory: 239704kb

input:

74998 952975592247715841

output:

NO

result:

ok single line: 'NO'

Test #58:

score: 0
Accepted
time: 15ms
memory: 239700kb

input:

74999 563899854863562881

output:

NO

result:

ok single line: 'NO'

Test #59:

score: 0
Accepted
time: 31ms
memory: 239640kb

input:

20 62119523114983182

output:

YES
20 19 18 17 16 9 1 2 4 3 5 7 6 8 10 11 12 13 14 15

result:

ok 2 lines

Test #60:

score: 0
Accepted
time: 16ms
memory: 239740kb

input:

20 62119523114983324

output:

NO

result:

ok single line: 'NO'

Test #61:

score: 0
Accepted
time: 87ms
memory: 245564kb

input:

125000 890645059675041665

output:

YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok 2 lines

Test #62:

score: 0
Accepted
time: 68ms
memory: 245500kb

input:

124997 1

output:

YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok 2 lines

Test #63:

score: 0
Accepted
time: 16ms
memory: 239644kb

input:

124998 873954992112723841

output:

NO

result:

ok single line: 'NO'

Test #64:

score: 0
Accepted
time: 47ms
memory: 239636kb

input:

124999 248632969637282529

output:

NO

result:

ok single line: 'NO'

Test #65:

score: 0
Accepted
time: 19ms
memory: 239772kb

input:

17 11501573822775

output:

YES
17 16 15 14 9 2 3 1 4 5 6 7 8 10 11 12 13

result:

ok 2 lines

Test #66:

score: 0
Accepted
time: 7ms
memory: 239632kb

input:

17 11501573823343

output:

NO

result:

ok single line: 'NO'

Test #67:

score: 0
Accepted
time: 118ms
memory: 248128kb

input:

175000 1000000000000000000

output:

YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok 2 lines

Test #68:

score: 0
Accepted
time: 137ms
memory: 248096kb

input:

174997 328322156846141249

output:

YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok 2 lines

Test #69:

score: 0
Accepted
time: 24ms
memory: 239696kb

input:

174998 184010129245469601

output:

NO

result:

ok single line: 'NO'

Test #70:

score: 0
Accepted
time: 31ms
memory: 239868kb

input:

174999 988653544556724225

output:

NO

result:

ok single line: 'NO'

Test #71:

score: 0
Accepted
time: 50ms
memory: 239700kb

input:

16 738680521137

output:

YES
16 15 14 13 6 1 2 3 4 7 5 8 9 10 11 12

result:

ok 2 lines

Test #72:

score: 0
Accepted
time: 33ms
memory: 239928kb

input:

16 738680521147

output:

NO

result:

ok single line: 'NO'

Test #73:

score: 0
Accepted
time: 162ms
memory: 251308kb

input:

250000 265999253667994753

output:

YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok 2 lines

Test #74:

score: 0
Accepted
time: 156ms
memory: 251672kb

input:

249997 1000000000000000000

output:

YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok 2 lines

Test #75:

score: 0
Accepted
time: 37ms
memory: 239672kb

input:

249998 994057636750856961

output:

NO

result:

ok single line: 'NO'

Test #76:

score: 0
Accepted
time: 37ms
memory: 239640kb

input:

249999 728689378265228289

output:

NO

result:

ok single line: 'NO'