QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#422448 | #8174. Set Construction | c20230201 | WA | 1ms | 3832kb | C++14 | 1.0kb | 2024-05-27 14:41:46 | 2024-05-27 14:41:49 |
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);
}
}
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