QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#586940 | #8004. Bit Component | ucup-team3519# | WA | 1ms | 3836kb | C++20 | 1.6kb | 2024-09-24 16:37:59 | 2024-09-24 16:37:59 |
Judging History
answer
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=300005;
const ll mod=998244353;
int G(int x){
return x^(x>>1);
}
vector<int>ans7={7,5,4,6,2,3,1};
vector<int>ans;
vector<int>follow[N];
void fill(int carry,int l,int r){
if(l<=r){
for(int i=l;i<=r;i++){
ans.push_back(carry^G(i));
}
}
else{
for(int i=l;i>=r;i--){
ans.push_back(carry^G(i));
}
}
}
void op(int x){
if(x==0){
cout<<"NO\n";
return;
}
cout<<"YES\n";
for(int i=0;i<ans.size();i++){
ll p=ans[i];
cout<<p<<' ';
for(int j=0;j<follow[p].size();j++){
cout<<follow[p][j]<<' ';
}
}
return;
}
void solve(){
int n;
cin>>n;
if(n<=7){
if(n==1){
ans={1};
op(1);
}
else if(n==3){
op(1);
}
else if(n==7){
ans=ans7;
op(1);
}
else{
op(0);
}
return;
}
ll lb;
for(int i=20;i>=0;i--){
if(n&(1<<i)){
lb=i;
break;
}
}
if(!(n&(1<<(lb-1)))){
op(0);
return;
}
if(n==(1<<lb)+(1<<(lb-1))){
op(0);
return;
}
for(int i=3;i<=lb;i++){
ans.push_back(1<<i);
ans.push_back((1<<i)+(1<<(i-1)));
}
fill(1<<lb,(1<<(lb-1))-1,1);
for(int i=(1<<lb)+(1<<(lb-1))+2;i<=n;i++){
follow[i-(1<<(lb-1))].push_back(i);
}
ans.push_back((1<<lb)+(1<<(lb-1))+1);
for(int b=lb-1;b>=3;b--){
fill((1<<b),1,(1<<b)-2);
// follow[(1<<b)].push_back((1<<b)+(1<<(b-1)));
}
for(int i=0;i<7;i++){
ans.push_back(ans7[i]);
}
op(1);
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
solve();
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3836kb
input:
1
output:
YES 1
result:
ok answer is 1
Test #2:
score: 0
Accepted
time: 1ms
memory: 3528kb
input:
2
output:
NO
result:
ok answer is 0
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3604kb
input:
3
output:
YES
result:
wrong output format Unexpected end of file - int32 expected