QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#350286#8004. Bit Componentjiangly (Lingyu Jiang)#WA 1ms3628kbC++201.6kb2024-03-10 16:45:132024-03-10 16:45:14

Judging History

This is the latest submission verdict.

  • [2024-03-10 16:45:14]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3628kb
  • [2024-03-10 16:45:13]
  • Submitted

answer

#include <bits/stdc++.h>

using i64 = long long;
using namespace std;
const int N=300005;
int n,q,fa[N];
vector<int> v[N];
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define pb push_back
vector<int> f(int n){
    if(n==0)return {};
    if(n==1)return {1};
    auto t=f(n/2),tt=t;
    int w=n/2+1;
    reverse(tt.begin(),tt.end());
    for(auto i:tt)t.pb(i+w);
    t.pb(w);
    return t;
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cin>>n;
    auto ans=f(7);
    //for(auto i:ans)cout<<i<<" "; return 0;
    if(n==1||n==3)ans=f(n);
    else{
        int t=log2(n),gb=(1<<t)+(1<<(t-1))+1;
        if(n<gb){
            puts("NO");
            return 0;
        }else{
            auto f1=f((1<<(t-1))-1),f2=f((1<<t)-1);
            f2.pop_back(); f2.pop_back(); f2.pb((1<<(t-1))+1);
            f2.pb(gb);
            for(auto i:f1)f2.pb(i+(1<<t));
            //for(auto i:f2)cerr<<i<<" "; cerr<<endl;
            ans={};
            for(auto i:f2){
                ans.pb(i);
                if((i>gb-(1<<t))&&i<=n-(1<<t)){
                    ans.pb(i+(1<<t));
                }
                if(i==(1<<(t-1))+(1<<(t-2))){ans.pb((1<<(t-1))); ans.pb((1<<(t-1))+(1<<t));}
            }
            ans.pb((1<<t));
        }
    }
    For(i,0,ans.size()-1)cout<<ans[i]<<(i==ans.size()-1?'\n':' ');
}
/*
14
1 3 2 6 7 5 4 pkuicpc2@pkuicpc:~/20240310$ cd "/home/pkuicpc2/20240310/" && g++ b.cpp -o b && "/home/pkuicpc2/20240310/"b
14
1 3 2 6 7 4 12 5 13 9 11 10 
1 3 2 6 14 7 4 12 5 13 9 11 10 8
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3628kb

input:

1

output:

1

result:

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