QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#309722#8004. Bit Componentucup-team139WA 0ms3668kbC++232.2kb2024-01-20 20:15:232024-01-20 20:15:23

Judging History

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

  • [2024-01-20 20:15:23]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3668kb
  • [2024-01-20 20:15:23]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

void solve(int t){
    int n;
    cin>>n;
    
    int pot=1;
    while(pot<=n)pot*=2ll;
    
    if(pot-1!=n){
        pot/=2ll;
        if(n-pot<=pot/2){
            cout<<"No\n";
        }else{
            cout<<"Yes\n";
            vector<int> ans = {0};
            
            while(ans.size()!=pot){
                vector<int> tmp;
                for(auto i : ans)tmp.push_back(i+ans.size());
                reverse(tmp.begin(),tmp.end());
                for(auto i : tmp)ans.push_back(i);
            }
            
            pot/=2;
            vector<int> ans2 = {0};
            while(ans2.size()!=pot){
                vector<int> tmp;
                for(auto i : ans2)tmp.push_back(i+ans2.size());
                reverse(tmp.begin(),tmp.end());
                for(auto i : tmp)ans2.push_back(i);
            }
            
            for(int i=1;i<ans.size();i++){
                cout<<ans[i]<<" ";
                
                if(ans[i]==pot*2-1 && ans[i+1]==pot*2-2){
                    for(int j=1;j<ans2.size();j++){
                        if(ans2[j]+pot*2+pot<=n)cout<<ans2[j]+pot*2+pot<<" ";
                        cout<<ans2[j]+pot*2<<" ";
                    }
                    cout<<pot*2<<" "<<pot*2+pot<<" ";
                }
                if(ans[i]==pot*2-2 && ans[i+1]==pot*2-1){
                    cout<<pot*2+pot<<" "<<pot*2<<" ";
                    for(int j=ans2.size()-1;j>0;j--){
                        cout<<ans2[j]+pot*2<<" ";
                        if(ans2[j]+pot*2+pot<=n)cout<<ans2[j]+pot*2+pot<<" ";
                    }
                }
            }
            cout<<"\n";
        }
    }else{
        cout<<"YES\n";
        vector<int> ans = {0};
        
        while(ans.size()!=pot){
            vector<int> tmp;
            for(auto i : ans)tmp.push_back(i+ans.size());
            reverse(tmp.begin(),tmp.end());
            for(auto i : tmp)ans.push_back(i);
        }
        
        for(int i=1;i<ans.size();i++)cout<<ans[i]<<" ";
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int t=1;
    //cin>>t;
    for(int i=1;i<=t;i++)solve(i);
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1

output:

YES
1 

result:

ok answer is 1

Test #2:

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

input:

2

output:

No

result:

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