QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#422466 | #8174. Set Construction | c20230201 | WA | 0ms | 3612kb | C++14 | 1.2kb | 2024-05-27 14:49:27 | 2024-05-27 14:49:28 |
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++) {
if(S[j]!=v) S[j]=S[j]<<1;
else 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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3612kb
input:
3 3 5 4 8 60 2
output:
0 4 2 6 7 0 8 4 12 2 10 6 15 0 1152921504606846975
result:
wrong answer (2 OR 12) is not in A