QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#423275 | #8174. Set Construction | cqbzly | WA | 0ms | 3856kb | C++14 | 1.0kb | 2024-05-27 22:01:24 | 2024-05-27 22:01:26 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define inf 0x3f3f3f3f
#define vi vector<ll>
using namespace std;
int T,n,m;
vector<ll>num;
void sol1(int x){
assert(x>=0);
ll y=0;
for(int i=x;i<n;i++)y+=1ll<<i;
num.pb(y);
}
void sol2(int x){
assert(x>=0);
int sz=num.size();
for(int i=0;i<sz;i++){
num.pb(num[i]+(1ll<<x));
}
}
int main(){
//freopen("data.in","r",stdin);
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
cin>>T;
while(T--){
cin>>n>>m;
vector<int>v;
int tmp=m;
while(tmp)v.pb(tmp&1),tmp>>=1;
reverse(v.begin(),v.end());
vector<int>vec;
if(v[1])vec.pb(0);
for(int i=2;i<v.size();i++){
vec.pb(1);
if(v[1])vec.pb(0);
}
int rest=n-1-vec.size();
ll val=1ll<<n-1;int cur=n-2;
for(int i=0;i<rest;i++){
val+=1ll<<cur;
cur--;
}
num.clear(),num.pb(0),num.pb(val);
for(auto e:vec){
if(!e)sol1(cur--);
else sol2(cur--);
}
for(auto e:num)cout<<e<<" ";
cout<<"\n";
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3856kb
input:
3 3 5 4 8 60 2
output:
0 6 1 7 0 12 2 14 1 13 3 15 0 1152921504606846975
result:
wrong answer Outputs are not distinct