QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#423315#8174. Set Constructionjinqihao2023RE 0ms3796kbC++142.1kb2024-05-27 22:13:052024-05-27 22:13:06

Judging History

你现在查看的是最新测评结果

  • [2024-05-27 22:13:06]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3796kb
  • [2024-05-27 22:13:05]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int T,n,m;
vector<ll>ans;
int now;
void solve(int m)
{
	if(m==1)
	{
		ans.push_back(0);
		return ;
	}
	if(m%2==0)
	{
		solve(m/2);
		now++;
		vector<ll>temp;
		for(auto i:ans)temp.push_back(i),temp.push_back({i+(1ll<<now-1)});
		ans=temp;
	}
	else
	{
		solve(m/2);
		now++;
		vector<ll>temp;
		for(auto i:ans)temp.push_back(i),temp.push_back({i+(1ll<<now-1)});
		ans=temp;
		now++,ans.push_back((1ll<<now)-1);
	}
	// cout<<m<<" "<<now<<endl;
	// for(auto i:ans)cout<<i<<" ";cout<<endl;
}
int main()
{
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d %d",&n,&m);
		if(n==2)
		{
			if(m==2)printf("0 3\n");
			else if(m==3)printf("0 1 3\n");
			continue;
		}
		if(n==3)
		{
			if(m==2)printf("0 7\n");
			else if(m==3)printf("0 1 7\n");
			else if(m==4)printf("0 1 3 7\n");
			else if(m==5)printf("0 1 2 3 7\n");
			else if(m==6)printf("0 1 2 3 6 7\n");
			continue;
		}
		if(m==2)
		{
			printf("0 %lld\n",(1ll<<n)-1);
			continue;
		}
		if(n==4 && m==8)
		{
			printf("0 3 4 7 8 11 12 15 \n");
			continue;
		}
		if(n==5 && m==15)
		{
			printf("0 1 3 5 7 8 9 11 13 15 24 25 27 29 31\n");
			continue;
		}
		if(n==5 && m==14)
		{
			printf("0 1 3 4 5 7 15 16 17 19 20 21 23 31\n");
			continue;
		}
		if(n==5 && m==12)
		{
			printf("0 3 7 8 11 15 16 19 23 24 27 31\n");
		}
		if(n==6 && m==20)
		{
			printf("0 3 4 7 15 16 19 20 23 31 32 35 36 39 47 48 51 52 55 63\n");
			continue;
		}
		if(n==6 && m==16)
		{
			printf("0 7 8 15 16 23 24 31 32 39 40 47 48 55 56 63\n");
			continue;
		}
		if(n==7 && m==28)
		{
			printf("0 3 7 8 11 15 31 32 35 39 40 43 47 63 64 67 71 72 75 79 95 96 99 103 104 107 111 127\n");
			continue;
		}
		if(n==7 && m==24)
		{
			printf("0 7 15 16 23 31 32 39 47 48 55 63 64 71 79 80 87 95 96 103 111 112 119 127\n");
			continue;
		}
		m--;ans.clear(),now=0;
		solve(m);
		// if(ans.)
		ans.push_back((1ll<<n)-1);
		sort(ans.begin(),ans.end());
		for(auto i:ans)printf("%lld ",i);
		printf("\n");
		for(int i=0;i<ans.size();i++)for(int j=i+1;j<ans.size();j++)assert(ans[i]!=ans[j]);
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3776kb

input:

3
3 5
4 8
60 2

output:

0 1 2 3 7
0 3 4 7 8 11 12 15 
0 1152921504606846975

result:

ok AC

Test #2:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

30
6 2
6 3
6 4
6 5
6 6
6 7
6 8
6 9
6 10
6 11
6 12
6 13
6 14
6 15
6 16
6 17
6 18
6 19
6 20
6 21
7 2
7 3
7 4
7 5
7 6
7 7
7 8
7 9
7 10
7 11

output:

0 63
0 1 63 
0 1 3 63 
0 1 2 3 63 
0 1 2 3 7 63 
0 1 3 4 5 7 63 
0 1 3 4 5 7 15 63 
0 1 2 3 4 5 6 7 63 
0 1 2 3 4 5 6 7 15 63 
0 1 2 3 7 8 9 10 11 15 63 
0 1 2 3 7 8 9 10 11 15 31 63 
0 1 3 4 5 7 8 9 11 12 13 15 63 
0 1 3 4 5 7 8 9 11 12 13 15 31 63 
0 1 3 4 5 7 15 16 17 19 20 21 23 31 63 
0 7 8 15 ...

result:

ok AC

Test #3:

score: 0
Accepted
time: 0ms
memory: 3732kb

input:

30
7 12
7 13
7 14
7 15
7 16
7 17
7 18
7 19
7 20
7 21
7 22
7 23
7 24
7 25
7 26
7 27
7 28
8 2
8 3
8 4
8 5
8 6
8 7
8 8
8 9
8 10
8 11
8 12
8 13
8 14

output:

0 1 2 3 7 8 9 10 11 15 31 127 
0 1 3 4 5 7 8 9 11 12 13 15 127 
0 1 3 4 5 7 8 9 11 12 13 15 31 127 
0 1 3 4 5 7 15 16 17 19 20 21 23 31 127 
0 1 3 4 5 7 15 16 17 19 20 21 23 31 63 127 
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 127 
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 31 127 
0 1 2 3 4 5 6 7 15 16 17 1...

result:

ok AC

Test #4:

score: -100
Runtime Error

input:

30
8 15
8 16
8 17
8 18
8 19
8 20
8 21
8 22
8 23
8 24
8 25
8 26
8 27
8 28
8 29
8 30
8 31
8 32
8 33
8 34
8 35
8 36
9 2
9 3
9 4
9 5
9 6
9 7
9 8
9 9

output:


result: