QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#422689 | #8174. Set Construction | Bronya | WA | 0ms | 3852kb | C++20 | 781b | 2024-05-27 18:38:40 | 2024-05-27 18:38:40 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,m;
int cnt,now,b[105];
long long a[5005];
void Solve(){
scanf("%d%d",&n,&m);
if(m==2){
printf("%lld %lld\n",0ll,(1ll<<n)-1);
return;
}
if(n==5&&m==15){
vector<int>ans;
ans={0,1,3,5,7,8,9,11,13,15,24,25,27,29,31};
for(auto x:ans)printf("%d ",x);
putchar('\n');
return;
}
cnt=0;
int s=0;
while(m)b[cnt++]=m&1,m>>=1;
b[now=1]=0;
for(int i=cnt-2;i>=0;i--){
for(int j=1;j<=now;j++)a[now+j]=a[j]|(1<<s);
now<<=1;s++;
if(b[i])s++,a[++now]=(1<<s)-1;
}
if(s!=n){
for(int i=1;i<=now;i++){
a[i]<<=n-s;
if(i>1)a[i]|=1;
}
}
for(int i=1;i<=now;i++)printf("%lld ",a[i]);
putchar('\n');
}
int main(){
int T;
scanf("%d",&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: 3852kb
input:
3 3 5 4 8 60 2
output:
0 1 2 3 7 0 3 5 7 9 11 13 15 0 1152921504606846975
result:
wrong answer (3 AND 5) is not in A