QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#645123#8004. Bit ComponenthezlikWA 0ms3800kbC++201.1kb2024-10-16 16:58:432024-10-16 16:58:44

Judging History

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

  • [2024-10-16 16:58:44]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3800kb
  • [2024-10-16 16:58:43]
  • 提交

answer

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

std::vector<int> Divide(int m){
  if (!m) return {1};
  auto a=Divide(m-1);
  auto b=a;
  std::reverse(a.begin(),a.end());
  for (int x:a)
    b.push_back(x|1<<m);
  b.push_back(1<<m);
  return b;
}

void solve(){
  int n;
  std::cin>>n;
  int m=0;
  for (int t=n;t;t>>=1) ++m;
  std::vector<int> ans;
  if (m<=3){
    if (n!=(1<<m)-1){
      std::cout<<"NO\n";
      return;
    }
    ans=Divide(m-1);
  }else{
    if (n<=(1<<(m-1)|1<<(m-2))){
      std::cout<<"NO\n";
      return;
    }
    // std::cerr<<" m : "<<m<<'\n';
    ans=Divide(m-2);
    ans.pop_back();
    // std::cerr<<" size : "<<ans.size()<<'\n';
    auto t=Divide(m-3);
    for (int x:t){
      x|=1<<(m-1);
      if ((x|1<<(m-2))<=n)
        ans.push_back(x|1<<(m-2));
      ans.push_back(x);
    }
    ans.push_back(1<<(m-1)|1<<(m-2));
    ans.push_back(1<<(m-2));
  }
  std::cout<<"YES\n";
  for (int x:ans)
    std::cout<<x<<' ';
  std::cout<<'\n';
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int T=1;
  while(T--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1

output:

YES
1 

result:

ok answer is 1

Test #2:

score: 0
Accepted
time: 0ms
memory: 3772kb

input:

2

output:

NO

result:

ok answer is 0

Test #3:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

3

output:

YES
1 3 2 

result:

ok answer is 1

Test #4:

score: 0
Accepted
time: 0ms
memory: 3776kb

input:

4

output:

NO

result:

ok answer is 0

Test #5:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

5

output:

NO

result:

ok answer is 0

Test #6:

score: 0
Accepted
time: 0ms
memory: 3468kb

input:

6

output:

NO

result:

ok answer is 0

Test #7:

score: 0
Accepted
time: 0ms
memory: 3520kb

input:

7

output:

YES
1 3 2 6 7 5 4 

result:

ok answer is 1

Test #8:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

8

output:

NO

result:

ok answer is 0

Test #9:

score: 0
Accepted
time: 0ms
memory: 3800kb

input:

9

output:

NO

result:

ok answer is 0

Test #10:

score: 0
Accepted
time: 0ms
memory: 3524kb

input:

10

output:

NO

result:

ok answer is 0

Test #11:

score: 0
Accepted
time: 0ms
memory: 3776kb

input:

11

output:

NO

result:

ok answer is 0

Test #12:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

12

output:

NO

result:

ok answer is 0

Test #13:

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

input:

13

output:

YES
1 3 2 6 7 5 13 9 11 10 12 4 

result:

wrong output format Unexpected end of file - int32 expected