QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#360666#8174. Set Constructionucup-team1198#WA 4ms3936kbC++201.3kb2024-03-21 23:57:072024-03-21 23:57:07

Judging History

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

  • [2024-03-21 23:57:07]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3936kb
  • [2024-03-21 23:57:07]
  • 提交

answer

#include <map>
#include <set>
#include <array>
#include <cmath>
#include <deque>
#include <bitset>
#include <random>
#include <string>
#include <vector>
#include <cassert>
#include <complex>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define int int64_t

pair<vector<int>, int> get(int m) {
    if (m == 2) {
        return {{0, 1}, 1};
    }
    if (m % 2 == 0) {
        auto res = get(m / 2);
        vector<int> ans;
        int n = res.second;
        for (int x : res.first) {
            ans.push_back(x);
            ans.push_back(x + (1ll << n));
        }
        return {ans, n + 1};
    }
    auto res = get(m - 1);
    res.second++;
    res.first.push_back((1ll << res.second) - 1);
    return res;
}

void solve() {
    int n, m;
    cin >> n >> m;
    auto res = get(m);
    int n1 = res.second;
    int add = (1ll << n) - (1ll << n1);
    for (int& x : res.first) {
        if (x % 2 == 1) {
            x += add;
        }
        cout << x << " ";
    }
    cout << "\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int tst;
    cin >> tst;
    while (tst--) {
        solve();
    }
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3608kb

input:

3
3 5
4 8
60 2

output:

0 2 1 3 7 
0 4 2 6 9 13 11 15 
0 1152921504606846975 

result:

ok AC

Test #2:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

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

output:

0 63 
0 61 63 
0 2 61 63 
0 2 57 59 63 
0 4 57 61 59 63 
0 4 49 53 51 55 63 
0 4 2 6 57 61 59 63 
0 4 2 6 49 53 51 55 63 
0 8 2 10 49 57 51 59 55 63 
0 8 2 10 33 41 35 43 39 47 63 
0 8 4 12 49 57 53 61 51 59 55 63 
0 8 4 12 33 41 37 45 35 43 39 47 63 
0 16 4 20 33 49 37 53 35 51 39 55 47 63 
0 16 4 ...

result:

ok AC

Test #3:

score: 0
Accepted
time: 0ms
memory: 3872kb

input:

30
7 12
7 13
7 14
7 15
7 16
7 17
7 18
7 19
7 20
7 21
7 22
7 23
7 24
7 25
7 26
7 27
7 28
8 2
8 3
8 4
8 5
8 6
8 7
8 8
8 9
8 10
8 11
8 12
8 13
8 14

output:

0 8 4 12 113 121 117 125 115 123 119 127 
0 8 4 12 97 105 101 109 99 107 103 111 127 
0 16 4 20 97 113 101 117 99 115 103 119 111 127 
0 16 4 20 65 81 69 85 67 83 71 87 79 95 127 
0 8 4 12 2 10 6 14 113 121 117 125 115 123 119 127 
0 8 4 12 2 10 6 14 97 105 101 109 99 107 103 111 127 
0 16 4 20 2 18...

result:

ok AC

Test #4:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

30
8 15
8 16
8 17
8 18
8 19
8 20
8 21
8 22
8 23
8 24
8 25
8 26
8 27
8 28
8 29
8 30
8 31
8 32
8 33
8 34
8 35
8 36
9 2
9 3
9 4
9 5
9 6
9 7
9 8
9 9

output:

0 16 4 20 193 209 197 213 195 211 199 215 207 223 255 
0 8 4 12 2 10 6 14 241 249 245 253 243 251 247 255 
0 8 4 12 2 10 6 14 225 233 229 237 227 235 231 239 255 
0 16 4 20 2 18 6 22 225 241 229 245 227 243 231 247 239 255 
0 16 4 20 2 18 6 22 193 209 197 213 195 211 199 215 207 223 255 
0 16 8 24 2...

result:

ok AC

Test #5:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

30
9 10
9 11
9 12
9 13
9 14
9 15
9 16
9 17
9 18
9 19
9 20
9 21
9 22
9 23
9 24
9 25
9 26
9 27
9 28
9 29
9 30
9 31
9 32
9 33
9 34
9 35
9 36
9 37
9 38
9 39

output:

0 8 2 10 497 505 499 507 503 511 
0 8 2 10 481 489 483 491 487 495 511 
0 8 4 12 497 505 501 509 499 507 503 511 
0 8 4 12 481 489 485 493 483 491 487 495 511 
0 16 4 20 481 497 485 501 483 499 487 503 495 511 
0 16 4 20 449 465 453 469 451 467 455 471 463 479 511 
0 8 4 12 2 10 6 14 497 505 501 509...

result:

ok AC

Test #6:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

6
9 40
9 41
9 42
9 43
9 44
9 45

output:

0 32 16 48 8 40 24 56 2 34 18 50 10 42 26 58 449 481 465 497 457 489 473 505 451 483 467 499 459 491 475 507 455 487 471 503 463 495 479 511 
0 32 16 48 8 40 24 56 2 34 18 50 10 42 26 58 385 417 401 433 393 425 409 441 387 419 403 435 395 427 411 443 391 423 407 439 399 431 415 447 511 
0 64 16 80 8...

result:

ok AC

Test #7:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

30
60 1801
60 1802
60 1803
60 1804
60 1805
60 1806
60 1807
60 1808
60 1809
60 1810
60 1811
60 1812
60 1813
60 1814
60 1815
60 1816
60 1817
60 1818
60 1819
60 1820
60 1821
60 1822
60 1823
60 1824
60 1825
60 1826
60 1827
60 1828
60 1829
60 1830

output:

0 4096 2048 6144 1024 5120 3072 7168 256 4352 2304 6400 1280 5376 3328 7424 128 4224 2176 6272 1152 5248 3200 7296 384 4480 2432 6528 1408 5504 3456 7552 64 4160 2112 6208 1088 5184 3136 7232 320 4416 2368 6464 1344 5440 3392 7488 192 4288 2240 6336 1216 5312 3264 7360 448 4544 2496 6592 1472 5568 3...

result:

ok AC

Test #8:

score: 0
Accepted
time: 4ms
memory: 3908kb

input:

30
59 1741
59 1742
59 1743
59 1744
59 1745
59 1746
59 1747
59 1748
59 1749
59 1750
59 1751
59 1752
59 1753
59 1754
59 1755
59 1756
59 1757
59 1758
59 1759
59 1760
59 1761
59 1762
59 1763
59 1764
59 1765
59 1766
59 1767
59 1768
59 1769
59 1770

output:

0 16384 8192 24576 2048 18432 10240 26624 512 16896 8704 25088 2560 18944 10752 27136 256 16640 8448 24832 2304 18688 10496 26880 768 17152 8960 25344 2816 19200 11008 27392 128 16512 8320 24704 2176 18560 10368 26752 640 17024 8832 25216 2688 19072 10880 27264 384 16768 8576 24960 2432 18816 10624 ...

result:

ok AC

Test #9:

score: 0
Accepted
time: 4ms
memory: 3936kb

input:

30
58 1682
58 1683
58 1684
58 1685
58 1686
58 1687
58 1688
58 1689
58 1690
58 1691
58 1692
58 1693
58 1694
58 1695
58 1696
58 1697
58 1698
58 1699
58 1700
58 1701
58 1702
58 1703
58 1704
58 1705
58 1706
58 1707
58 1708
58 1709
58 1710
58 1711

output:

0 8192 2048 10240 1024 9216 3072 11264 512 8704 2560 10752 1536 9728 3584 11776 128 8320 2176 10368 1152 9344 3200 11392 640 8832 2688 10880 1664 9856 3712 11904 64 8256 2112 10304 1088 9280 3136 11328 576 8768 2624 10816 1600 9792 3648 11840 192 8384 2240 10432 1216 9408 3264 11456 704 8896 2752 10...

result:

ok AC

Test #10:

score: -100
Wrong Answer
time: 0ms
memory: 3576kb

input:

30
2 2
2 3
3 2
3 3
3 4
3 5
3 6
4 2
4 3
4 4
4 5
4 6
4 7
4 8
4 9
4 10
5 2
5 3
5 4
5 5
5 6
5 7
5 8
5 9
5 10
5 11
5 12
5 13
5 14
5 15

output:

0 3 
0 1 3 
0 7 
0 5 7 
0 2 5 7 
0 2 1 3 7 
0 4 1 5 3 7 
0 15 
0 13 15 
0 2 13 15 
0 2 9 11 15 
0 4 9 13 11 15 
0 4 1 5 3 7 15 
0 4 2 6 9 13 11 15 
0 4 2 6 1 5 3 7 15 
0 8 2 10 1 9 3 11 7 15 
0 31 
0 29 31 
0 2 29 31 
0 2 25 27 31 
0 4 25 29 27 31 
0 4 17 21 19 23 31 
0 4 2 6 25 29 27 31 
0 4 2 6 17...

result:

wrong answer Integer element [index=5] equals to -31, violates the range [0, 31]