QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#465808#8004. Bit Componentucup-team052#WA 0ms3792kbC++231.7kb2024-07-07 10:16:252024-07-07 10:16:26

Judging History

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

  • [2024-07-07 10:16:26]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3792kb
  • [2024-07-07 10:16:25]
  • 提交

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;
}



Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1

output:

YES
1

result:

ok answer is 1

Test #2:

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

input:

2

output:

NO

result:

ok answer is 0

Test #3:

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

input:

3

output:

YES
1 3 2

result:

ok answer is 1

Test #4:

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

input:

4

output:

NO

result:

ok answer is 0

Test #5:

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

input:

5

output:

NO

result:

ok answer is 0

Test #6:

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

input:

6

output:

NO

result:

ok answer is 0

Test #7:

score: -100
Wrong Answer
time: 0ms
memory: 3792kb

input:

7

output:

7
YES
1 3 2 7 5 4 6

result:

wrong output format YES or NO expected in answer, but 7 found