QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#343446 | #8004. Bit Component | ucup-team1525# | WA | 1ms | 4076kb | C++17 | 1.6kb | 2024-03-02 16:20:24 | 2024-03-02 16:20:24 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int n;
int main()
{
// int n=4;
// for (int i=0;i<(1<<n);++i)
// {
// int x=i^(i>>1);
// for (int j=n-1;j>=0;--j)
// printf("%d",(x>>j)&1);
// puts("");
// }
// printf("%b\n",i^(i>>1))
scanf("%d",&n);
if (n<=6)
{
if (n==1)
{
puts("YES");
puts("1");
}
if (n==3)
{
puts("YES");
puts("2 3 1");
}
if (n==2||n==4||n==5||n==6)
puts("NO");
return 0;
}
int p=0;
while ((1<<p)<=n)
++p;
int q=(1<<p);
if (q*7/8>n)
{
puts("NO");
return 0;
}
vector<int> ans;
for (int i=1;i<(1<<p);++i)
{
int x=i^(i>>1);
if (x>n)
continue;
int o=x>>(p-2);
if (o==0)
{
ans.push_back(x);
}
if (o==1)
{
ans.push_back(x);
if (x+(1<<(p-1))<=n&&(o<<(p-2)!=x))
ans.push_back(x+(1<<(p-1)));
}
if (o==2)
{
ans.push_back(x);
}
if (o==3)
{
if ((o<<(p-2))==x)
ans.push_back(x);
}
// ans.push_back(x);
// if (i>=(1<<(p-2))&&x+(1<<(p-1))<=n)
// if ()
}
puts("YES");
for (int x:ans)
printf("%d ",x);
// sort(ans.begin(),ans.end());
// for (int i=0;i<n;++i)
// if (ans[i]!=i+1)
// puts("gg");
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3952kb
input:
1
output:
YES 1
result:
ok answer is 1
Test #2:
score: 0
Accepted
time: 1ms
memory: 3652kb
input:
2
output:
NO
result:
ok answer is 0
Test #3:
score: 0
Accepted
time: 0ms
memory: 3940kb
input:
3
output:
YES 2 3 1
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: 3664kb
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: 1ms
memory: 4076kb
input:
7
output:
YES 1 3 7 2 6 5 4
result:
wrong answer Participant's answer is incorrect