QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#370633 | #8174. Set Construction | Harry27182 | WA | 0ms | 3756kb | C++14 | 2.4kb | 2024-03-29 14:15:48 | 2024-03-29 14:15:49 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
vector<int>res[15][105];int T,n,m;
vector<int> solve(int n,int m)
{
if(n<6)return res[n][m];
if(m<=n*(n-1)/2)
{
vector<int>ans=solve(n-1,m);
for(int i=0;i<ans.size();i++)ans[i]=(2*ans[i])+(ans[i]&1);
return ans;
}
if(m%2==0)
{
vector<int>now=solve(n-1,m/2),ans;
for(int i=0;i<now.size();i++)
{
ans.emplace_back(now[i]*2);
ans.emplace_back(now[i]*2+1);
}
return ans;
}
else
{
vector<int>ans=solve(n-1,m-1);
for(int i=0;i<ans.size();i++)ans[i]=2*ans[i]+1;
ans.emplace_back(0);return ans;
}
}
int main()
{
cin.tie(0)->sync_with_stdio(0);
res[2][2].resize(2);
res[2][2]={0,3};
res[2][3].resize(3);
res[2][3]={0,1,3};
res[3][2].resize(2);
res[3][2]={0,7};
res[3][3].resize(3);
res[3][3]={0,1,7};
res[3][4].resize(4);
res[3][4]={0,1,3,7};
res[3][5].resize(5);
res[3][5]={0,1,2,3,7};
res[3][6].resize(6);
res[3][6]={0,1,2,3,5,7};
res[4][2].resize(2);
res[4][2]={0,15};
res[4][3].resize(3);
res[4][3]={0,1,15};
res[4][4].resize(4);
res[4][4]={0,1,3,15};
res[4][5].resize(5);
res[4][5]={0,1,2,3,15};
res[4][6].resize(6);
res[4][6]={0,1,2,3,7,15};
res[4][7].resize(7);
res[4][7]={0,1,2,3,5,7,15};
res[4][8].resize(8);
res[4][8]={0,1,2,3,5,7,11,15};
res[4][9].resize(9);
res[4][9]={0,1,2,3,4,5,6,7,15};
res[4][10].resize(10);
res[4][10]={0,1,2,3,4,5,6,7,11,15};
res[5][2].resize(2);
res[5][2]={0,31};
res[5][3].resize(3);
res[5][3]={0,1,31};
res[5][4].resize(4);
res[5][4]={0,1,3,31};
res[5][5].resize(5);
res[5][5]={0,1,2,3,31};
res[5][6].resize(6);
res[5][6]={0,1,2,3,7,31};
res[5][7].resize(7);
res[5][7]={0,1,2,3,5,7,31};
res[5][8].resize(8);
res[5][8]={0,1,2,3,5,7,15,31};
res[5][9].resize(9);
res[5][9]={0,1,2,3,4,5,6,7,31};
res[5][10].resize(10);
res[5][10]={0,1,2,3,4,5,6,7,15,31};
res[5][11].resize(11);
res[5][11]={0,1,2,3,4,5,6,7,11,15,31};
res[5][12].resize(12);
res[5][12]={0,1,2,3,4,5,6,7,11,15,23,31};
res[5][13].resize(13);
res[5][13]={0,1,2,3,4,5,6,7,9,11,13,15,31};
res[5][14].resize(14);
res[5][14]={0,1,2,3,4,5,6,7,9,11,13,15,23,31};
res[5][15].resize(15);
res[5][15]={0,1,2,3,4,5,6,7,12,13,14,15,19,23,31};
cin>>T;
while(T--)
{
cin>>n>>m;
vector<int>ans=solve(n,m);
for(int i=0;i<ans.size();i++)cout<<ans[i]<<' ';
cout<<'\n';
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3756kb
input:
3 3 5 4 8 60 2
output:
0 1 2 3 7 0 1 2 3 5 7 11 15 0 -1
result:
wrong answer Integer element [index=2] equals to -1, violates the range [0, 1152921504606846975]