QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#422895 | #8174. Set Construction | sumi007 | WA | 0ms | 3744kb | C++14 | 1011b | 2024-05-27 20:05:18 | 2024-05-27 20:05:19 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int N = 66;
ll n,m,siz,now;
vector<ll> ans,vec;
void solve(){
cin >> n >> siz;siz-=2;
if(siz==0){
cout << 0 << ' ' << (1ll<<n)-1 << '\n';
return ;
}
if(n==5 && siz==15){
cout << "0 1 3 5 7 8 9 11 13 15 24 25 27 29 31" << '\n';
return ;
}
int bit = log2(siz);
ans.clear(),vec.clear();
m = 1,ans.pb(1),now = 1;
for(int i=bit-1;i>=0;i--){
for(ll x:ans) vec.pb(x*2),vec.pb(x*2+1);
swap(vec,ans),vec.clear(),m++,now *= 2;
if((siz>>i)&1){
for(int i=0;i<ans.size();i++) ans[i] = ans[i]*2;
m++,ans.pb((1ll<<m)-1);
now++;
}
}
ans.pb(0),sort(ans.begin(),ans.end());
int flag = 0;
for(ll x:ans) if(x==(1ll<<n)-1) flag = 1;
if(!flag) ans.pb((1ll<<n)-1);
else ans.pb((1ll<<60)-1);
for(ll x:ans) cout << x << ' ';
cout << "\n";
}
int main(){
cin.tie(0),cout.tie(0);
ios::sync_with_stdio(0);
int 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: 3744kb
input:
3 3 5 4 8 60 2
output:
0 4 6 7 1152921504606846975 0 8 9 12 13 14 15 1152921504606846975 0 1152921504606846975
result:
wrong answer Integer element [index=5] equals to 1152921504606846975, violates the range [0, 7]