QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#423851 | #8174. Set Construction | Iratis | WA | 1ms | 3920kb | C++14 | 1.3kb | 2024-05-28 18:23:49 | 2024-05-28 18:23:49 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define md(a) a=(a%mod+mod)%mod
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
bool ST;
int n,m,S;
namespace Force
{
vector<int>a,ans;bool vst[1<<16];
inline void check()
{
if((int)a.size()!=m)return ;
for(int x:a)for(int y:a)if(!vst[x&y]||!vst[x|y])return ;ans=a;
}
void dfs(int k)
{
if(k==S){check();return ;}
a.push_back(k),vst[k]=1,dfs(k+1),a.pop_back(),vst[k]=0;if(k>0&&k<S-1)dfs(k+1);
}
inline void main(){if(m==2){cout<<0<<' '<<S-1<<'\n';return ;}dfs(0);for(int x:ans)cout<<x<<' ';cout<<'\n';}
};
vector<int>ans;
inline void solve()
{
cin>>n>>m,S=(1ll<<n);if(n<=3||m==2){Force::main();return ;}ans.clear(),ans.push_back(0),m--;
int x=0;vector<int>op;while(m>1){if(m&1)op.push_back(1),m--;else op.push_back(2),m/=2;}reverse(op.begin(),op.end());
for(int o:op)
{
if(o==1)ans.push_back(1ll<<x),x++;
else {vector<int>t=ans;for(int w:t)ans.push_back(w|(1ll<<x));x++;}
}
ans.push_back(S-1);for(int x:ans)cout<<x<<' ';cout<<'\n';
}
bool ED;
signed main()
{
int time_st=clock();
cerr<<(&ST-&ED)/1024.0/1024<<endl;ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int T;cin>>T;while(T--)solve();
cerr<<(clock()-time_st)/1e6<<endl;return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3920kb
input:
3 3 5 4 8 60 2
output:
0 4 5 6 7 0 1 2 4 5 6 8 15 0 1152921504606846975
result:
wrong answer (1 OR 2) is not in A