QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#343450#8004. Bit Componentucup-team1525#WA 0ms3952kbC++171.6kb2024-03-02 16:26:162024-03-02 16:26:18

Judging History

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

  • [2024-03-02 16:26:18]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3952kb
  • [2024-03-02 16:26:16]
  • 提交

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);
    int oo=q/8*7;
    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&&(x+(1<<p-1)!=oo))
                ans.push_back(x+(1<<(p-1)));
        }
        if (o==2)
        {
            ans.push_back(x);
        }
        if (o==3)
        {
            if (x==oo)
                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: 0ms
memory: 3712kb

input:

1

output:

YES
1

result:

ok answer is 1

Test #2:

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

input:

2

output:

NO

result:

ok answer is 0

Test #3:

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

input:

3

output:

YES
2 3 1

result:

ok answer is 1

Test #4:

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

input:

4

output:

NO

result:

ok answer is 0

Test #5:

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

input:

5

output:

NO

result:

ok answer is 0

Test #6:

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

input:

6

output:

NO

result:

ok answer is 0

Test #7:

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

input:

7

output:

YES
1 3 2 6 7 5 4 

result:

ok answer is 1

Test #8:

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

input:

8

output:

NO

result:

ok answer is 0

Test #9:

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

input:

9

output:

NO

result:

ok answer is 0

Test #10:

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

input:

10

output:

NO

result:

ok answer is 0

Test #11:

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

input:

11

output:

NO

result:

ok answer is 0

Test #12:

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

input:

12

output:

NO

result:

ok answer is 0

Test #13:

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

input:

13

output:

NO

result:

wrong answer Jury has the answer, participant doesn't