QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#423323#8174. Set Constructionjinqihao2023RE 20ms4116kbC++142.4kb2024-05-27 22:15:342024-05-27 22:15:35

Judging History

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

  • [2024-05-27 22:15:35]
  • 评测
  • 测评结果:RE
  • 用时:20ms
  • 内存:4116kb
  • [2024-05-27 22:15:34]
  • 提交

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==10)
		{
			printf("0 1 2 3 7 8 9 10 11 15\n");
			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;
		}
		if(n==8 && m==32)
		{
			printf("0 15 16 31 32 47 48 63 64 79 80 95 96 111 112 127 128 143 144 159 160 175 176 191 192 207 208 223 224 239 240 255\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: 4024kb

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: 4060kb

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: 3772kb

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: 0
Accepted
time: 0ms
memory: 3776kb

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:

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

result:

ok AC

Test #5:

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

input:

30
9 10
9 11
9 12
9 13
9 14
9 15
9 16
9 17
9 18
9 19
9 20
9 21
9 22
9 23
9 24
9 25
9 26
9 27
9 28
9 29
9 30
9 31
9 32
9 33
9 34
9 35
9 36
9 37
9 38
9 39

output:

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

result:

ok AC

Test #6:

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

input:

6
9 40
9 41
9 42
9 43
9 44
9 45

output:

0 1 2 3 4 5 6 7 15 16 17 18 19 20 21 22 23 31 63 64 65 66 67 68 69 70 71 79 80 81 82 83 84 85 86 87 95 127 255 511 
0 1 2 3 7 8 9 10 11 15 16 17 18 19 23 24 25 26 27 31 32 33 34 35 39 40 41 42 43 47 48 49 50 51 55 56 57 58 59 63 511 
0 1 2 3 7 8 9 10 11 15 16 17 18 19 23 24 25 26 27 31 32 33 34 35 3...

result:

ok AC

Test #7:

score: 0
Accepted
time: 20ms
memory: 3864kb

input:

30
60 1801
60 1802
60 1803
60 1804
60 1805
60 1806
60 1807
60 1808
60 1809
60 1810
60 1811
60 1812
60 1813
60 1814
60 1815
60 1816
60 1817
60 1818
60 1819
60 1820
60 1821
60 1822
60 1823
60 1824
60 1825
60 1826
60 1827
60 1828
60 1829
60 1830

output:

0 1 3 4 5 7 15 16 17 19 20 21 23 31 32 33 35 36 37 39 47 48 49 51 52 53 55 63 64 65 67 68 69 71 79 80 81 83 84 85 87 95 96 97 99 100 101 103 111 112 113 115 116 117 119 127 128 129 131 132 133 135 143 144 145 147 148 149 151 159 160 161 163 164 165 167 175 176 177 179 180 181 183 191 192 193 195 196...

result:

ok AC

Test #8:

score: 0
Accepted
time: 15ms
memory: 3832kb

input:

30
59 1741
59 1742
59 1743
59 1744
59 1745
59 1746
59 1747
59 1748
59 1749
59 1750
59 1751
59 1752
59 1753
59 1754
59 1755
59 1756
59 1757
59 1758
59 1759
59 1760
59 1761
59 1762
59 1763
59 1764
59 1765
59 1766
59 1767
59 1768
59 1769
59 1770

output:

0 1 3 4 5 7 8 9 11 12 13 15 31 32 33 35 36 37 39 40 41 43 44 45 47 63 127 128 129 131 132 133 135 136 137 139 140 141 143 159 160 161 163 164 165 167 168 169 171 172 173 175 191 255 256 257 259 260 261 263 264 265 267 268 269 271 287 288 289 291 292 293 295 296 297 299 300 301 303 319 383 384 385 38...

result:

ok AC

Test #9:

score: 0
Accepted
time: 14ms
memory: 4116kb

input:

30
58 1682
58 1683
58 1684
58 1685
58 1686
58 1687
58 1688
58 1689
58 1690
58 1691
58 1692
58 1693
58 1694
58 1695
58 1696
58 1697
58 1698
58 1699
58 1700
58 1701
58 1702
58 1703
58 1704
58 1705
58 1706
58 1707
58 1708
58 1709
58 1710
58 1711

output:

0 1 3 4 5 7 8 9 11 12 13 15 31 32 33 35 36 37 39 40 41 43 44 45 47 63 64 65 67 68 69 71 72 73 75 76 77 79 95 96 97 99 100 101 103 104 105 107 108 109 111 127 128 129 131 132 133 135 136 137 139 140 141 143 159 160 161 163 164 165 167 168 169 171 172 173 175 191 192 193 195 196 197 199 200 201 203 20...

result:

ok AC

Test #10:

score: -100
Runtime Error

input:

30
2 2
2 3
3 2
3 3
3 4
3 5
3 6
4 2
4 3
4 4
4 5
4 6
4 7
4 8
4 9
4 10
5 2
5 3
5 4
5 5
5 6
5 7
5 8
5 9
5 10
5 11
5 12
5 13
5 14
5 15

output:


result: