QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#343501#8004. Bit Componentucup-team1525WA 1ms3940kbC++172.3kb2024-03-02 17:45:292024-03-02 17:45:29

Judging History

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

  • [2024-03-02 17:45:29]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3940kb
  • [2024-03-02 17:45:29]
  • 提交

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<=7)
    {
        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");
        if (n==7)
        {
            puts("YES");
            puts("7 5 4 6 2 3 1");
        }
        return 0;
    }
    int p=0;
    while ((1<<p)<=n)
        ++p;
    int q=(1<<p);
    int oo=q/4*3+1;
    // cout<<oo<<endl;
    if (oo>n)
    {
        puts("NO");
        return 0;
    }
    vector<int> ans,ans1;
    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)
        {
            if ((x+1)==(1<<(p-1)))
            {
                ans.push_back(1<<(p-2));
                if ((1<<(p-2))+(1<<(p-1))<=n)
                    ans.push_back((1<<(p-2))+(1<<(p-1)));
            }
            if (x==(1<<p-2))
                continue;
            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)
        {
            ans1.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);
    for (int x:ans1)
        ans.push_back(x);
    ans1.pop_back();
    for (int i=ans1.size()-1;i>=0;--i)
        printf("%d ",ans1[i]);
    printf("%d",(1<<(p-1)));
    // sort(ans.begin(),ans.end());
    // for (int i=0;i<n;++i)
    //     if (ans[i]!=i+1)
    //         puts("gg");
    return 0;
}

// 01111111
// ...
// 01000001
// 01000000
// 11000001
// 10000001
/*
001
011
010
110
111
101
100
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1

output:

YES
1

result:

ok answer is 1

Test #2:

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

input:

2

output:

NO

result:

ok answer is 0

Test #3:

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

input:

3

output:

YES
2 3 1

result:

ok answer is 1

Test #4:

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

input:

4

output:

NO

result:

ok answer is 0

Test #5:

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

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: 3644kb

input:

7

output:

YES
7 5 4 6 2 3 1

result:

ok answer is 1

Test #8:

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

input:

8

output:

NO

result:

ok answer is 0

Test #9:

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

input:

9

output:

NO

result:

ok answer is 0

Test #10:

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

input:

10

output:

NO

result:

ok answer is 0

Test #11:

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

input:

11

output:

NO

result:

ok answer is 0

Test #12:

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

input:

12

output:

NO

result:

ok answer is 0

Test #13:

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

input:

13

output:

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

result:

ok answer is 1

Test #14:

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

input:

14

output:

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

result:

ok answer is 1

Test #15:

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

input:

15

output:

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

result:

ok answer is 1

Test #16:

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

input:

16

output:

NO

result:

ok answer is 0

Test #17:

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

input:

17

output:

NO

result:

ok answer is 0

Test #18:

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

input:

23

output:

NO

result:

ok answer is 0

Test #19:

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

input:

24

output:

NO

result:

ok answer is 0

Test #20:

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

input:

25

output:

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

result:

wrong answer Participant's answer is incorrect