QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#304470#8004. Bit Componentucup-team191#AC ✓11ms4580kbC++231.4kb2024-01-13 20:10:052024-01-13 20:10:05

Judging History

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

  • [2024-01-13 20:10:05]
  • 评测
  • 测评结果:AC
  • 用时:11ms
  • 内存:4580kb
  • [2024-01-13 20:10:05]
  • 提交

answer

#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using vl=vector<ll>;
#define pb push_back
#define all(a) begin(a),end(a)

const int N=300010,MOD=1e9+7;
const char en='\n';
const ll LLINF=1ll<<60;

vi getCons(int x)
{
	if (x==0)
	{
		return {1};
	}
	vi z=getCons(x-1);
	vi um=z;
	reverse(all(um));
	vi v;
	v.pb(1);
	for (auto x: z) v.pb(x*2+1);
	for (auto x: um) v.pb(x*2);
	return v;
}

int n;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	if (n<=7)
	{
		if (n&(n+1))
		{
			cout<<"NO\n";
			exit(0);
		}
		cout<<"YES\n";
		vi v=getCons(__lg(n));
		for (auto x: v) cout<<x<<' ';
		cout<<en;
		exit(0);
	}
	int l=__lg(n);
	if (n<=(3<<(l-1)))
	{
		cout<<"NO\n";
		exit(0);
	}
	vi v;
	vi temp=getCons(l-3);
	for (auto x: temp) v.pb(x*2);
	reverse(all(temp));
	for (auto x: temp) v.pb(x*2+(1<<(l-1)));
	v.pb(1<<(l-1));
	v.pb(3<<(l-1));
	v.pb(1<<l);
	for (auto x: temp) v.pb(x*2+(1<<l));
	reverse(all(temp));
	for (auto x: temp) v.pb(x*2+(1<<l)+1);
	v.pb((1<<l)+1);
	v.pb((3<<(l-1))+1);
	v.pb((1<<(l-1))+1);
	for (auto x: temp) v.pb(x*2+(1<<(l-1))+1);
	v.pb(1);
	for (auto x: temp) v.pb(x*2+1);
	cout<<"YES\n";
	for (auto x: v)
	{
		cout<<x<<' ';
		if (x+(1<<l)>(3<<(l-1))+1 && x+(1<<l)<=n) cout<<x+(1<<l)<<' ';
	}
	cout<<en;
}

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

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

input:

1

output:

YES
1 

result:

ok answer is 1

Test #2:

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

input:

2

output:

NO

result:

ok answer is 0

Test #3:

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

input:

3

output:

YES
1 3 2 

result:

ok answer is 1

Test #4:

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

input:

4

output:

NO

result:

ok answer is 0

Test #5:

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

input:

5

output:

NO

result:

ok answer is 0

Test #6:

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

input:

6

output:

NO

result:

ok answer is 0

Test #7:

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

input:

7

output:

YES
1 3 7 5 4 6 2 

result:

ok answer is 1

Test #8:

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

input:

8

output:

NO

result:

ok answer is 0

Test #9:

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

input:

9

output:

NO

result:

ok answer is 0

Test #10:

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

input:

10

output:

NO

result:

ok answer is 0

Test #11:

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

input:

11

output:

NO

result:

ok answer is 0

Test #12:

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

input:

12

output:

NO

result:

ok answer is 0

Test #13:

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

input:

13

output:

YES
2 6 4 12 8 10 11 9 13 5 7 1 3 

result:

ok answer is 1

Test #14:

score: 0
Accepted
time: 1ms
memory: 3824kb

input:

14

output:

YES
2 6 14 4 12 8 10 11 9 13 5 7 1 3 

result:

ok answer is 1

Test #15:

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

input:

15

output:

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

result:

ok answer is 1

Test #16:

score: 0
Accepted
time: 1ms
memory: 3504kb

input:

16

output:

NO

result:

ok answer is 0

Test #17:

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

input:

17

output:

NO

result:

ok answer is 0

Test #18:

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

input:

23

output:

NO

result:

ok answer is 0

Test #19:

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

input:

24

output:

NO

result:

ok answer is 0

Test #20:

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

input:

25

output:

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

result:

ok answer is 1

Test #21:

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

input:

26

output:

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

result:

ok answer is 1

Test #22:

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

input:

27

output:

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

result:

ok answer is 1

Test #23:

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

input:

40

output:

NO

result:

ok answer is 0

Test #24:

score: 0
Accepted
time: 1ms
memory: 3544kb

input:

53

output:

YES
2 6 14 10 8 12 4 20 52 28 24 26 30 22 18 50 16 48 32 36 44 40 42 46 38 34 35 39 47 43 41 45 37 33 49 17 19 51 23 31 27 25 29 21 53 1 3 7 15 11 9 13 5 

result:

ok answer is 1

Test #25:

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

input:

93

output:

NO

result:

ok answer is 0

Test #26:

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

input:

105

output:

YES
2 6 14 30 22 18 26 10 8 24 16 20 28 12 4 36 100 44 60 52 48 56 40 104 42 58 50 54 62 46 38 102 34 98 32 96 64 68 76 92 84 80 88 72 74 90 82 86 94 78 70 66 67 71 79 95 87 83 91 75 73 89 81 85 93 77 69 65 97 33 35 99 39 103 47 63 55 51 59 43 41 105 57 49 53 61 45 37 101 1 3 7 15 31 23 19 27 11 9 2...

result:

ok answer is 1

Test #27:

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

input:

132

output:

NO

result:

ok answer is 0

Test #28:

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

input:

221

output:

YES
2 6 14 30 62 46 38 54 22 18 50 34 42 58 26 10 8 24 56 40 32 48 16 20 52 36 44 60 28 12 4 68 196 76 204 92 220 124 108 100 116 84 212 80 208 112 96 104 120 88 216 72 200 74 202 90 218 122 106 98 114 82 210 86 214 118 102 110 126 94 78 206 70 198 66 194 64 192 128 132 140 156 188 172 164 180 148 1...

result:

ok answer is 1

Test #29:

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

input:

373

output:

NO

result:

ok answer is 0

Test #30:

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

input:

473

output:

YES
2 6 14 30 62 126 94 78 110 46 38 102 70 86 118 54 22 18 50 114 82 66 98 34 42 106 74 90 122 58 26 10 8 24 56 120 88 72 104 40 32 96 64 80 112 48 16 20 52 116 84 68 100 36 44 108 76 92 124 60 28 12 4 132 388 140 396 156 412 188 444 252 220 204 460 236 172 428 164 420 228 196 452 212 468 244 180 4...

result:

ok answer is 1

Test #31:

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

input:

513

output:

NO

result:

ok answer is 0

Test #32:

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

input:

934

output:

YES
2 6 14 30 62 126 254 190 158 222 94 78 206 142 174 238 110 46 38 102 230 166 134 198 70 86 214 150 182 246 118 54 22 18 50 114 242 178 146 210 82 66 194 130 162 226 98 34 42 106 234 170 138 202 74 90 218 154 186 250 122 58 26 10 8 24 56 120 248 184 152 216 88 72 200 136 168 232 104 40 32 96 224 ...

result:

ok answer is 1

Test #33:

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

input:

1356

output:

NO

result:

ok answer is 0

Test #34:

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

input:

1651

output:

YES
2 6 14 30 62 126 254 510 382 318 446 190 158 414 286 350 478 222 94 78 206 462 334 270 398 142 174 430 302 366 494 238 110 46 38 102 230 486 358 294 422 166 134 390 262 326 454 198 70 86 214 470 342 278 406 150 182 438 310 374 502 246 118 54 22 18 50 114 242 498 370 306 434 178 146 402 274 338 4...

result:

ok answer is 1

Test #35:

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

input:

2263

output:

NO

result:

ok answer is 0

Test #36:

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

input:

3330

output:

YES
2 6 14 30 62 126 254 510 1022 766 638 894 382 318 830 574 702 958 446 190 158 414 926 670 542 798 286 350 862 606 734 990 478 222 94 78 206 462 974 718 590 846 334 270 782 526 654 910 398 142 174 430 942 686 558 814 302 366 878 622 750 1006 494 238 110 46 38 102 230 486 998 742 614 870 358 294 8...

result:

ok answer is 1

Test #37:

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

input:

4375

output:

NO

result:

ok answer is 0

Test #38:

score: 0
Accepted
time: 1ms
memory: 3684kb

input:

7989

output:

YES
2 6 14 30 62 126 254 510 1022 2046 1534 1278 1790 766 638 1662 1150 1406 1918 894 382 318 830 1854 1342 1086 1598 574 702 1726 1214 1470 1982 958 446 190 158 414 926 1950 1438 1182 1694 670 542 1566 1054 1310 1822 798 286 350 862 1886 1374 1118 1630 606 734 1758 1246 1502 2014 990 478 222 94 78 ...

result:

ok answer is 1

Test #39:

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

input:

10925

output:

NO

result:

ok answer is 0

Test #40:

score: 0
Accepted
time: 1ms
memory: 3684kb

input:

14097

output:

YES
2 6 14 30 62 126 254 510 1022 2046 4094 3070 2558 3582 1534 1278 3326 2302 2814 3838 1790 766 638 1662 3710 2686 2174 3198 1150 1406 3454 2430 2942 3966 1918 894 382 318 830 1854 3902 2878 2366 3390 1342 1086 3134 2110 2622 3646 1598 574 702 1726 3774 2750 2238 3262 1214 1470 3518 2494 3006 4030...

result:

ok answer is 1

Test #41:

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

input:

16893

output:

NO

result:

ok answer is 0

Test #42:

score: 0
Accepted
time: 2ms
memory: 3904kb

input:

28913

output:

YES
2 6 14 30 62 126 254 510 1022 2046 4094 8190 6142 5118 7166 3070 2558 6654 4606 5630 7678 3582 1534 1278 3326 7422 5374 4350 6398 2302 2814 6910 4862 5886 7934 3838 1790 766 638 1662 3710 7806 5758 4734 6782 2686 2174 6270 4222 5246 7294 3198 1150 1406 3454 7550 5502 4478 6526 2430 2942 7038 499...

result:

ok answer is 1

Test #43:

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

input:

40092

output:

NO

result:

ok answer is 0

Test #44:

score: 0
Accepted
time: 3ms
memory: 3780kb

input:

54980

output:

YES
2 6 14 30 62 126 254 510 1022 2046 4094 8190 16382 12286 10238 14334 6142 5118 13310 9214 11262 15358 7166 3070 2558 6654 14846 10750 8702 12798 4606 5630 13822 9726 11774 15870 7678 3582 1534 1278 3326 7422 15614 11518 9470 13566 5374 4350 12542 8446 10494 14590 6398 2302 2814 6910 15102 11006 ...

result:

ok answer is 1

Test #45:

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

input:

88104

output:

NO

result:

ok answer is 0

Test #46:

score: 0
Accepted
time: 3ms
memory: 3812kb

input:

106284

output:

YES
2 6 14 30 62 126 254 510 1022 2046 4094 8190 16382 32766 24574 20478 28670 12286 10238 26622 18430 22526 30718 14334 6142 5118 13310 29694 21502 17406 25598 9214 11262 27646 19454 23550 31742 15358 7166 3070 2558 6654 14846 31230 23038 18942 27134 10750 8702 25086 16894 20990 29182 12798 4606 56...

result:

ok answer is 1

Test #47:

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

input:

152797

output:

NO

result:

ok answer is 0

Test #48:

score: 0
Accepted
time: 11ms
memory: 4580kb

input:

200000

output:

YES
2 6 14 30 62 126 254 510 1022 2046 4094 8190 16382 32766 65534 49150 40958 57342 24574 20478 53246 36862 45054 61438 28670 12286 10238 26622 59390 43006 34814 51198 18430 22526 55294 38910 47102 63486 30718 14334 6142 5118 13310 29694 62462 46078 37886 54270 21502 17406 50174 33790 41982 58366 2...

result:

ok answer is 1

Test #49:

score: 0
Accepted
time: 1ms
memory: 3592kb

input:

3073

output:

YES
2 6 14 30 62 126 254 510 1022 766 638 894 382 318 830 574 702 958 446 190 158 414 926 670 542 798 286 350 862 606 734 990 478 222 94 78 206 462 974 718 590 846 334 270 782 526 654 910 398 142 174 430 942 686 558 814 302 366 878 622 750 1006 494 238 110 46 38 102 230 486 998 742 614 870 358 294 8...

result:

ok answer is 1

Test #50:

score: 0
Accepted
time: 1ms
memory: 3724kb

input:

16383

output:

YES
2 6 14 30 62 126 254 510 1022 2046 4094 3070 2558 3582 1534 1278 3326 2302 2814 3838 1790 766 638 1662 3710 2686 2174 3198 1150 1406 3454 2430 2942 3966 1918 894 382 318 830 1854 3902 2878 2366 3390 1342 1086 3134 2110 2622 3646 1598 574 702 1726 3774 2750 2238 3262 1214 1470 3518 2494 3006 4030...

result:

ok answer is 1

Test #51:

score: 0
Accepted
time: 2ms
memory: 3684kb

input:

32767

output:

YES
2 6 14 30 62 126 254 510 1022 2046 4094 8190 6142 5118 7166 3070 2558 6654 4606 5630 7678 3582 1534 1278 3326 7422 5374 4350 6398 2302 2814 6910 4862 5886 7934 3838 1790 766 638 1662 3710 7806 5758 4734 6782 2686 2174 6270 4222 5246 7294 3198 1150 1406 3454 7550 5502 4478 6526 2430 2942 7038 499...

result:

ok answer is 1

Test #52:

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

input:

399

output:

YES
2 6 14 30 62 126 94 78 110 46 38 102 70 86 118 54 22 18 50 114 82 66 98 34 42 106 74 90 122 58 26 10 8 24 56 120 88 72 104 40 32 96 64 80 112 48 16 20 52 116 84 68 100 36 44 108 76 92 124 60 28 12 4 132 388 140 396 156 188 252 220 204 236 172 164 228 196 212 244 180 148 144 176 240 208 192 224 1...

result:

ok answer is 1

Test #53:

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

input:

5757

output:

NO

result:

ok answer is 0

Test #54:

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

input:

179

output:

NO

result:

ok answer is 0

Test #55:

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

input:

228

output:

YES
2 6 14 30 62 46 38 54 22 18 50 34 42 58 26 10 8 24 56 40 32 48 16 20 52 36 44 60 28 12 4 68 196 76 204 92 220 124 108 100 228 116 84 212 80 208 112 96 224 104 120 88 216 72 200 74 202 90 218 122 106 98 226 114 82 210 86 214 118 102 110 126 94 222 78 206 70 198 66 194 64 192 128 132 140 156 188 1...

result:

ok answer is 1

Extra Test:

score: 0
Extra Test Passed