QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#304679 | #8004. Bit Component | ucup-team197# | WA | 1ms | 3508kb | C++14 | 862b | 2024-01-13 23:53:57 | 2024-01-13 23:53:58 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);cin.tie(0);
int n;cin >> n;
if(n<=3){
if(n==1) cout << "YES\n1\n";
if(n==2) cout << "NO\n";
if(n==3) cout << "YES\2 3 1\n";
return 0;
}
int k=1;
while((1<<(k+1))<=n) ++k;
if(n<=(1<<k)+(1<<(k-1))){
cout << "NO\n";
return 0;
}
vector<int>v={1};
for(int i=1; i<=k-1 ;i++){
int m=v.size();
for(int j=m-1; j>=0 ;j--) v.push_back(v[j]+(1<<i));
v.push_back(1<<i);
}
cout << "YES\n";
reverse(v.begin(),v.end());
int frog=(1<<k)+(1<<(k-1))+1;
for(auto c:v){
cout << c << " ";
if((c>>(k-1))&1){
if(c+(1<<k)!=frog) cout << c+(1<<k) << ' ';
}
}
cout << frog << ' ';
reverse(v.begin(),v.end());
for(int i=0; i<(1<<(k-1))-1 ;i++){
cout << v[i]+(1<<k) << ' ';
}
cout << frog-1 << ' ' << (1<<k) << '\n';
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3476kb
input:
1
output:
YES 1
result:
ok answer is 1
Test #2:
score: 0
Accepted
time: 1ms
memory: 3432kb
input:
2
output:
NO
result:
ok answer is 0
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3508kb
input:
3
output:
YES\x02 3 1
result:
wrong output format YES or NO expected in answer, but YES\x02 found