QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#350832#8174. Set Constructionucup-team2307WA 8ms3796kbC++201.5kb2024-03-11 06:53:032024-03-11 06:53:04

Judging History

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

  • [2024-03-11 06:53:04]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:3796kb
  • [2024-03-11 06:53:03]
  • 提交

answer

#include<bits/stdc++.h>

#define fi first
#define se second
#define pb push_back

using namespace std;

typedef long long ll;
#define int ll

set<int> st(int n, int m)
{
    if (n == 0)
        return {};

    if (m <= n + 1)
    {
        set<int> res;
        int s = 0;
        for (int i=1; i<m; i++)
            res.insert(s), s = 2*s + 1;
        res.insert({(1ll<<n) - 1});
        return res;
    }

    if (m%2 == 0)
    {
        set<int> r = st(n-1, m/2);
        if (r.empty())
            return {};
        set<int> res;
        for (int i : r)
        {
            res.insert(2*i);
            res.insert(2*i+1);
        }
        return res;
    }
    else
    {
        set<int> r = st(n-1, m-1);
        if (r.empty())
            return {};
        set<int> res = {(1<<n) - 1};
        for (int i : r)
            res.insert(2*i);
        return res;
    }
}

main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin>>t;
    while (t--)
    {
        int n, m;
        cin>>n>>m;
        if (n==5 && m==15)
        {
            for (int i: st(2, 3))
                for (int j : st(3, 5))
                    cout<<(i<<3)+j<<" ";
            cout<<"\n";
            continue;
        }

        for (int i : st(n, m))
            cout<<i<<" ";
        cout<<"\n";
    }
//    for (int n = 2; ; n++)
//        for (int m = 2; m<=n*(n+1)/2; m++)
//            if (st(n, m).empty())
//                cout<<"WA "<<n<<" "<<m<<endl;
}


详细

Test #1:

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

input:

3
3 5
4 8
60 2

output:

0 2 4 6 7 
0 1 2 3 6 7 14 15 
0 1152921504606846975 

result:

ok AC

Test #2:

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

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 1 63 
0 1 3 63 
0 1 3 7 63 
0 1 3 7 15 63 
0 1 3 7 15 31 63 
0 1 2 3 6 7 62 63 
0 2 4 6 12 14 60 62 63 
0 1 2 3 6 7 14 15 62 63 
0 2 4 6 12 14 28 30 60 62 63 
0 1 2 3 6 7 14 15 30 31 62 63 
0 2 4 6 8 10 12 14 56 58 60 62 63 
0 1 4 5 8 9 12 13 56 57 60 61 62 63 
0 2 8 10 16 18 24 26 48 50 56 ...

result:

ok AC

Test #3:

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

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 1 2 3 6 7 14 15 30 31 126 127 
0 2 4 6 12 14 28 30 60 62 124 126 127 
0 1 2 3 6 7 14 15 30 31 62 63 126 127 
0 2 8 10 16 18 24 26 112 114 120 122 124 126 127 
0 1 2 3 4 5 6 7 12 13 14 15 124 125 126 127 
0 2 4 6 8 10 12 14 24 26 28 30 120 122 124 126 127 
0 1 4 5 8 9 12 13 24 25 28 29 120 121 124 ...

result:

ok AC

Test #4:

score: 0
Accepted
time: 1ms
memory: 3600kb

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 2 4 6 12 14 28 30 60 62 124 126 252 254 255 
0 1 2 3 6 7 14 15 30 31 62 63 126 127 254 255 
0 2 4 6 8 10 12 14 24 26 28 30 248 250 252 254 255 
0 1 4 5 8 9 12 13 24 25 28 29 248 249 252 253 254 255 
0 2 8 10 16 18 24 26 48 50 56 58 240 242 248 250 252 254 255 
0 1 2 3 4 5 6 7 12 13 14 15 28 29 30 ...

result:

ok AC

Test #5:

score: 0
Accepted
time: 1ms
memory: 3796kb

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 1 3 7 15 31 63 127 255 511 
0 2 4 6 12 14 28 30 508 510 511 
0 1 2 3 6 7 14 15 30 31 510 511 
0 2 4 6 12 14 28 30 60 62 508 510 511 
0 1 2 3 6 7 14 15 30 31 62 63 510 511 
0 2 4 6 12 14 28 30 60 62 124 126 508 510 511 
0 1 2 3 6 7 14 15 30 31 62 63 126 127 510 511 
0 2 4 6 12 14 28 30 60 62 124 12...

result:

ok AC

Test #6:

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

input:

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

output:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31 56 57 58 59 60 61 62 63 504 505 506 507 508 509 510 511 
0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 48 50 52 54 56 58 60 62 112 114 116 118 120 122 124 126 496 498 500 502 504 506 508 510 511 
0 1 4 5 8 9 12 13 16 17 20 21 24 25 28 29 48 ...

result:

ok AC

Test #7:

score: -100
Wrong Answer
time: 8ms
memory: 3672kb

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 2 4 6 8 10 12 14 32 34 36 38 40 42 44 46 64 66 68 70 72 74 76 78 96 98 100 102 104 106 108 110 128 130 132 134 136 138 140 142 160 162 164 166 168 170 172 174 192 194 196 198 200 202 204 206 224 226 228 230 232 234 236 238 256 258 260 262 264 266 268 270 288 290 292 294 296 298 300 302 320 322 324...

result:

wrong answer 1152921504606846975 is not in A