QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#422461#8174. Set Constructionc20230201WA 0ms3492kbC++141.1kb2024-05-27 14:48:202024-05-27 14:48:20

Judging History

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

  • [2024-05-27 14:48:20]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3492kb
  • [2024-05-27 14:48:20]
  • 提交

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);
            }
        }
        while(v!=(1ll<<n)-1) {
            for(ll j=0;j<S.size();j++) S[j]=S[j]<<1|1;
            v=v<<1|1;
        }
        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;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3492kb

input:

3
3 5
4 8
60 2

output:

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

result:

wrong answer 0 is not in A