QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#422461 | #8174. Set Construction | c20230201 | WA | 0ms | 3492kb | C++14 | 1.1kb | 2024-05-27 14:48:20 | 2024-05-27 14:48:20 |
Judging History
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