QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#369486 | #8174. Set Construction | edisnimorF | WA | 0ms | 3996kb | C++14 | 1.7kb | 2024-03-28 11:42:38 | 2024-03-28 11:42:40 |
Judging History
answer
#include<bits/stdc++.h>
#define il inline
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define pii pair<int, int>
#define fr first
#define sc second
#define ll long long
#define eb emplace_back
#define mset(f, z) memset(f, z, sizeof(f))
#define mcpy(f, g) memcpy(f, g, sizeof(g))
using namespace std;
template<typename T=ll>
il T rd(){
T s=0; bool f=1; char c=getchar();
while(!isdigit(c)) f^=(c=='-'), c=getchar();
while(isdigit(c)) s=s*10+c-'0', c=getchar();
return f? s:-s;
}
template<typename T> il void ckmx(T &x, T y){if(x<y) x=y;}
template<typename T> il void ckmn(T &x, T y){if(y<x) x=y;}
char _begin;
int n, m, p;
ll real(int l, int r){ll re=0; for(int i=l; i<=r; i++) re|=1ll<<i; return re;}
ll holl(int l, int r){ll re=0; for(int i=l; i<=r; i++) re|=(i!=p)*1ll<<i; return re;}
void solve(){
n=rd(), m=rd();
if(m==2) return printf("%lld %lld\n", 0ll, (1ll<<n)-1), void();
vector<ll> ans;
ans.eb(0), ans.eb((1ll<<n)-1);
m-=2;
p=n/2;
#define insert(xxx) \
{ ans.eb(xxx);\
if(!--m) goto finish; }
insert(1ll<<p);
for(int i=1; p-i>=0 && p+i<n; i++){
if(p-i>0 || p+i!=n-1) insert(real(p-i, p+i));
for(int j=p+i-1; j>=p; j--) insert(real(p-i, j));
for(int j=p-i+1; j<=p; j++) insert(real(j, p+i));
for(int j=p; j<=p+i-1; j++) insert(holl(p-i, j));
for(int j=p; j>=p-i+1; j--) insert(holl(j, p+i));
insert(holl(p-i, p+i));
}
if(m){
insert(real(0, n-2));
if(--m) insert(holl(0, n-2));
}
finish:;
for(ll i:ans) printf("%lld ", i);
puts("");
}
char _end;
signed main(){
debug("%lfMB\n", (&_end-&_begin)/1024./1024.);
int T=rd();
while(T--) solve();
return 0;
}
/*
3
3 5
4 8
60 2
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3996kb
input:
3 3 5 4 8 60 2
output:
0 7 2 3 6 0 15 4 14 6 12 2 8 0 1152921504606846975
result:
wrong answer (2 OR 8) is not in A