QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#422448#8174. Set Constructionc20230201WA 1ms3832kbC++141.0kb2024-05-27 14:41:462024-05-27 14:41:49

Judging History

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

  • [2024-05-27 14:41:49]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3832kb
  • [2024-05-27 14:41:46]
  • 提交

answer

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

typedef long long ll;

void solve() {
    ll n,m; cin>>n>>m;
    if(m==(1<<n)) {
        for(int i=0;i<(1<<n);i++) cout<<i<<' '; cout<<'\n';
    }else {
        vector<ll> S;
        S.push_back(0);
        ll x=m, v=0;
        vector<ll> op;
        while(x) {
            op.push_back(x&1);
            x>>=1;
        }
        reverse(op.begin(),op.end());
        for(ll i=1;i<op.size();i++) {
            v=(v<<1|1);
            ll t=S.size();
            for(ll j=0;j<t;j++) {
                S[j]<<=1;
                S.push_back(S[j]|1);
            }
            if(op[i]) {
                v=v<<1|1;
                for(ll j=0;j<S.size();j++) S[j]<<=1;
                S.push_back(v);
            }
        }
        for(ll i=0;i<S.size();i++) cout<<S[i]<<' '; cout<<'\n';
        }
    return ;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    ll T; cin>>T;
    while(T--) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3832kb

input:

3
3 5
4 8
60 2

output:

0 4 2 6 7 
0 4 2 6 1 5 3 7 
0 1 

result:

wrong answer 15 is not in A