QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#309722 | #8004. Bit Component | ucup-team139 | WA | 0ms | 3668kb | C++23 | 2.2kb | 2024-01-20 20:15:23 | 2024-01-20 20:15:23 |
Judging History
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