QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#465809#8004. Bit Componentucup-team052#AC ✓11ms4484kbC++231.7kb2024-07-07 10:17:272024-07-07 10:17:29

Judging History

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

  • [2024-07-07 10:17:29]
  • 评测
  • 测评结果:AC
  • 用时:11ms
  • 内存:4484kb
  • [2024-07-07 10:17:27]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define mod 998244353
#define ll long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
void print(vector<int> x){for(int i=0;i<(int)x.size();i++) printf("%d%c",x[i]," \n"[i==(int)x.size()-1]);}
#define N 200005
int ans[N],cnt;
signed main()
{
	int n=read();
	if(n==3)
	{
		printf("YES\n");
		printf("1 3 2\n");
		return 0;
	}
	if(n==1)
	{
		printf("YES\n");
		printf("1\n");
		return 0;
	}
	if(__builtin_popcount(n)==1)
	{
		printf("NO\n");
		return 0;
	}
	int l=0;
	while((1<<(l+1))<n) l++;
	// l++;
	ans[++cnt]=1,ans[++cnt]=3,ans[++cnt]=2;
	for(int i=2;i<l;i++)
	{
		int tc=cnt;
		for(int j=tc;j>=1;j--)
		{
			ans[++cnt]=ans[j]|(1<<i);
			if(ans[j]==(1<<(i-1))) ans[++cnt]=1<<i;
		}
	}

	if(n-(1<<l)<=1<<(l-1))
	{
		cout<<"NO\n";
		return 0;
	}
	ans[++cnt]=(1<<l)+(1<<(l-1))+1;
	for(int i=1;i<(1<<(l-1));i++)
	{
		ans[++cnt]=ans[i]|(1<<l);
		if((ans[i]|(1<<l)|(1<<(l-1)))<=n)
		{
			if(ans[i]!=1) ans[++cnt]=ans[i]|(1<<l)|(1<<(l-1));
		}
	}
	ans[++cnt]=1<<l;
	if(((1<<l)|(1<<(l-1)))<=n) ans[++cnt]=(1<<l)|(1<<(l-1));
	
	// assert(cnt==n);
	// cout<<cnt<<endl;
	
	cout<<"YES\n";
	for(int i=1;i<=n;i++) printf("%d%c",ans[i]," \n"[i==n]);
	
	// for(int i=1;i<=n;i++)
	// {
		// for(int j=0;j<=l;j++) printf("%d",ans[i]>>j&1);
		// cout<<"\n";
	// }
	// for(int i=1;i<n;i++) assert(ans[i]&ans[i+1]);
	return 0;
}



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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1

output:

YES
1

result:

ok answer is 1

Test #2:

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

input:

2

output:

NO

result:

ok answer is 0

Test #3:

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

input:

3

output:

YES
1 3 2

result:

ok answer is 1

Test #4:

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

input:

4

output:

NO

result:

ok answer is 0

Test #5:

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

input:

5

output:

NO

result:

ok answer is 0

Test #6:

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

input:

6

output:

NO

result:

ok answer is 0

Test #7:

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

input:

7

output:

YES
1 3 2 7 5 4 6

result:

ok answer is 1

Test #8:

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

input:

8

output:

NO

result:

ok answer is 0

Test #9:

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

input:

9

output:

NO

result:

ok answer is 0

Test #10:

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

input:

10

output:

NO

result:

ok answer is 0

Test #11:

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

input:

11

output:

NO

result:

ok answer is 0

Test #12:

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

input:

12

output:

NO

result:

ok answer is 0

Test #13:

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

input:

13

output:

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

result:

ok answer is 1

Test #14:

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

input:

14

output:

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

result:

ok answer is 1

Test #15:

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

input:

15

output:

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

result:

ok answer is 1

Test #16:

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

input:

16

output:

NO

result:

ok answer is 0

Test #17:

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

input:

17

output:

NO

result:

ok answer is 0

Test #18:

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

input:

23

output:

NO

result:

ok answer is 0

Test #19:

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

input:

24

output:

NO

result:

ok answer is 0

Test #20:

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

input:

25

output:

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

result:

ok answer is 1

Test #21:

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

input:

26

output:

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

result:

ok answer is 1

Test #22:

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

input:

27

output:

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

result:

ok answer is 1

Test #23:

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

input:

40

output:

NO

result:

ok answer is 0

Test #24:

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

input:

53

output:

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

result:

ok answer is 1

Test #25:

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

input:

93

output:

NO

result:

ok answer is 0

Test #26:

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

input:

105

output:

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

result:

ok answer is 1

Test #27:

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

input:

132

output:

NO

result:

ok answer is 0

Test #28:

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

input:

221

output:

YES
1 3 2 6 4 7 5 13 15 12 8 14 10 11 9 25 27 26 30 24 16 28 31 29 21 23 20 22 18 19 17 49 51 50 54 52 55 53 61 63 60 48 32 56 62 58 59 57 41 43 42 46 40 44 47 45 37 39 36 38 34 35 33 97 99 98 102 100 103 101 109 111 108 104 110 106 107 105 121 123 122 126 120 96 64 112 124 127 125 117 119 116 118 1...

result:

ok answer is 1

Test #29:

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

input:

373

output:

NO

result:

ok answer is 0

Test #30:

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

input:

473

output:

YES
1 3 2 6 4 7 5 13 15 12 8 14 10 11 9 25 27 26 30 24 16 28 31 29 21 23 20 22 18 19 17 49 51 50 54 52 55 53 61 63 60 48 32 56 62 58 59 57 41 43 42 46 40 44 47 45 37 39 36 38 34 35 33 97 99 98 102 100 103 101 109 111 108 104 110 106 107 105 121 123 122 126 120 96 64 112 124 127 125 117 119 116 118 1...

result:

ok answer is 1

Test #31:

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

input:

513

output:

NO

result:

ok answer is 0

Test #32:

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

input:

934

output:

YES
1 3 2 6 4 7 5 13 15 12 8 14 10 11 9 25 27 26 30 24 16 28 31 29 21 23 20 22 18 19 17 49 51 50 54 52 55 53 61 63 60 48 32 56 62 58 59 57 41 43 42 46 40 44 47 45 37 39 36 38 34 35 33 97 99 98 102 100 103 101 109 111 108 104 110 106 107 105 121 123 122 126 120 96 64 112 124 127 125 117 119 116 118 1...

result:

ok answer is 1

Test #33:

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

input:

1356

output:

NO

result:

ok answer is 0

Test #34:

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

input:

1651

output:

YES
1 3 2 6 4 7 5 13 15 12 8 14 10 11 9 25 27 26 30 24 16 28 31 29 21 23 20 22 18 19 17 49 51 50 54 52 55 53 61 63 60 48 32 56 62 58 59 57 41 43 42 46 40 44 47 45 37 39 36 38 34 35 33 97 99 98 102 100 103 101 109 111 108 104 110 106 107 105 121 123 122 126 120 96 64 112 124 127 125 117 119 116 118 1...

result:

ok answer is 1

Test #35:

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

input:

2263

output:

NO

result:

ok answer is 0

Test #36:

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

input:

3330

output:

YES
1 3 2 6 4 7 5 13 15 12 8 14 10 11 9 25 27 26 30 24 16 28 31 29 21 23 20 22 18 19 17 49 51 50 54 52 55 53 61 63 60 48 32 56 62 58 59 57 41 43 42 46 40 44 47 45 37 39 36 38 34 35 33 97 99 98 102 100 103 101 109 111 108 104 110 106 107 105 121 123 122 126 120 96 64 112 124 127 125 117 119 116 118 1...

result:

ok answer is 1

Test #37:

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

input:

4375

output:

NO

result:

ok answer is 0

Test #38:

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

input:

7989

output:

YES
1 3 2 6 4 7 5 13 15 12 8 14 10 11 9 25 27 26 30 24 16 28 31 29 21 23 20 22 18 19 17 49 51 50 54 52 55 53 61 63 60 48 32 56 62 58 59 57 41 43 42 46 40 44 47 45 37 39 36 38 34 35 33 97 99 98 102 100 103 101 109 111 108 104 110 106 107 105 121 123 122 126 120 96 64 112 124 127 125 117 119 116 118 1...

result:

ok answer is 1

Test #39:

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

input:

10925

output:

NO

result:

ok answer is 0

Test #40:

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

input:

14097

output:

YES
1 3 2 6 4 7 5 13 15 12 8 14 10 11 9 25 27 26 30 24 16 28 31 29 21 23 20 22 18 19 17 49 51 50 54 52 55 53 61 63 60 48 32 56 62 58 59 57 41 43 42 46 40 44 47 45 37 39 36 38 34 35 33 97 99 98 102 100 103 101 109 111 108 104 110 106 107 105 121 123 122 126 120 96 64 112 124 127 125 117 119 116 118 1...

result:

ok answer is 1

Test #41:

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

input:

16893

output:

NO

result:

ok answer is 0

Test #42:

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

input:

28913

output:

YES
1 3 2 6 4 7 5 13 15 12 8 14 10 11 9 25 27 26 30 24 16 28 31 29 21 23 20 22 18 19 17 49 51 50 54 52 55 53 61 63 60 48 32 56 62 58 59 57 41 43 42 46 40 44 47 45 37 39 36 38 34 35 33 97 99 98 102 100 103 101 109 111 108 104 110 106 107 105 121 123 122 126 120 96 64 112 124 127 125 117 119 116 118 1...

result:

ok answer is 1

Test #43:

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

input:

40092

output:

NO

result:

ok answer is 0

Test #44:

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

input:

54980

output:

YES
1 3 2 6 4 7 5 13 15 12 8 14 10 11 9 25 27 26 30 24 16 28 31 29 21 23 20 22 18 19 17 49 51 50 54 52 55 53 61 63 60 48 32 56 62 58 59 57 41 43 42 46 40 44 47 45 37 39 36 38 34 35 33 97 99 98 102 100 103 101 109 111 108 104 110 106 107 105 121 123 122 126 120 96 64 112 124 127 125 117 119 116 118 1...

result:

ok answer is 1

Test #45:

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

input:

88104

output:

NO

result:

ok answer is 0

Test #46:

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

input:

106284

output:

YES
1 3 2 6 4 7 5 13 15 12 8 14 10 11 9 25 27 26 30 24 16 28 31 29 21 23 20 22 18 19 17 49 51 50 54 52 55 53 61 63 60 48 32 56 62 58 59 57 41 43 42 46 40 44 47 45 37 39 36 38 34 35 33 97 99 98 102 100 103 101 109 111 108 104 110 106 107 105 121 123 122 126 120 96 64 112 124 127 125 117 119 116 118 1...

result:

ok answer is 1

Test #47:

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

input:

152797

output:

NO

result:

ok answer is 0

Test #48:

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

input:

200000

output:

YES
1 3 2 6 4 7 5 13 15 12 8 14 10 11 9 25 27 26 30 24 16 28 31 29 21 23 20 22 18 19 17 49 51 50 54 52 55 53 61 63 60 48 32 56 62 58 59 57 41 43 42 46 40 44 47 45 37 39 36 38 34 35 33 97 99 98 102 100 103 101 109 111 108 104 110 106 107 105 121 123 122 126 120 96 64 112 124 127 125 117 119 116 118 1...

result:

ok answer is 1

Test #49:

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

input:

3073

output:

YES
1 3 2 6 4 7 5 13 15 12 8 14 10 11 9 25 27 26 30 24 16 28 31 29 21 23 20 22 18 19 17 49 51 50 54 52 55 53 61 63 60 48 32 56 62 58 59 57 41 43 42 46 40 44 47 45 37 39 36 38 34 35 33 97 99 98 102 100 103 101 109 111 108 104 110 106 107 105 121 123 122 126 120 96 64 112 124 127 125 117 119 116 118 1...

result:

ok answer is 1

Test #50:

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

input:

16383

output:

YES
1 3 2 6 4 7 5 13 15 12 8 14 10 11 9 25 27 26 30 24 16 28 31 29 21 23 20 22 18 19 17 49 51 50 54 52 55 53 61 63 60 48 32 56 62 58 59 57 41 43 42 46 40 44 47 45 37 39 36 38 34 35 33 97 99 98 102 100 103 101 109 111 108 104 110 106 107 105 121 123 122 126 120 96 64 112 124 127 125 117 119 116 118 1...

result:

ok answer is 1

Test #51:

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

input:

32767

output:

YES
1 3 2 6 4 7 5 13 15 12 8 14 10 11 9 25 27 26 30 24 16 28 31 29 21 23 20 22 18 19 17 49 51 50 54 52 55 53 61 63 60 48 32 56 62 58 59 57 41 43 42 46 40 44 47 45 37 39 36 38 34 35 33 97 99 98 102 100 103 101 109 111 108 104 110 106 107 105 121 123 122 126 120 96 64 112 124 127 125 117 119 116 118 1...

result:

ok answer is 1

Test #52:

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

input:

399

output:

YES
1 3 2 6 4 7 5 13 15 12 8 14 10 11 9 25 27 26 30 24 16 28 31 29 21 23 20 22 18 19 17 49 51 50 54 52 55 53 61 63 60 48 32 56 62 58 59 57 41 43 42 46 40 44 47 45 37 39 36 38 34 35 33 97 99 98 102 100 103 101 109 111 108 104 110 106 107 105 121 123 122 126 120 96 64 112 124 127 125 117 119 116 118 1...

result:

ok answer is 1

Test #53:

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

input:

5757

output:

NO

result:

ok answer is 0

Test #54:

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

input:

179

output:

NO

result:

ok answer is 0

Test #55:

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

input:

228

output:

YES
1 3 2 6 4 7 5 13 15 12 8 14 10 11 9 25 27 26 30 24 16 28 31 29 21 23 20 22 18 19 17 49 51 50 54 52 55 53 61 63 60 48 32 56 62 58 59 57 41 43 42 46 40 44 47 45 37 39 36 38 34 35 33 97 99 98 102 100 103 101 109 111 108 104 110 106 107 105 121 123 122 126 120 96 64 112 124 127 125 117 119 116 118 1...

result:

ok answer is 1

Extra Test:

score: 0
Extra Test Passed