QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#306567 | #8004. Bit Component | ucup-team2303 | WA | 1ms | 4008kb | C++17 | 1.6kb | 2024-01-16 21:47:30 | 2024-01-16 21:47:30 |
Judging History
answer
// #pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define PB emplace_back
// #define int long long
#define ll long long
#define vi vector<int>
#define siz(a) ((int) ((a).size()))
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
void print(vi n) { rep(i, 0, siz(n) - 1) cerr << n[i] << " \n"[i == siz(n) - 1]; }
vi get(int n) {
if(n == 1) return vi{0};
vi x = get(n >> 1), y = x;
reverse(y.begin(), y.end());
for(int z : y) x.PB(z + (n >> 1));
return x;
}
signed main() {
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int a, b;
cin >> a;
if(a == 1) return cout << "YES\n1", 0;
if(a == 3) return cout << "YES\n1 3 2", 0;
for(b = 1; (b << 1) <= a; b <<= 1);
if(b + b / 2 + 1 > a) return cout << "NO", 0;
cout << "YES\n";
vi n = get(b >> 1), ans;
ans.PB(b), ans.PB(b + b / 2);
rep(i, 1, siz(n) - 1) {
ans.PB(n[i] + b);
if(n[i] + b + b / 2 <= a && n[i] != 1) ans.PB(n[i] + b + b / 2);
}
ans.PB(1 + b + b / 2);
n = get(b);
reverse(next(n.begin()), n.end());
rep(i, 1, siz(n) - 1) ans.PB(n[i]);
for(int x : ans) cout << x << ' ';
cout << '\n';
cerr << siz(ans) << '\n';
for(int x : ans) {
per(j, 10, 0) cerr << ((x >> j) & 1);
cerr << '\n';
}
return cerr << endl << 1.0 * clock() / CLOCKS_PER_SEC << endl, 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
input:
1
output:
YES 1
result:
ok answer is 1
Test #2:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
2
output:
NO
result:
ok answer is 0
Test #3:
score: 0
Accepted
time: 0ms
memory: 3488kb
input:
3
output:
YES 1 3 2
result:
ok answer is 1
Test #4:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
4
output:
NO
result:
ok answer is 0
Test #5:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
5
output:
NO
result:
ok answer is 0
Test #6:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
6
output:
NO
result:
ok answer is 0
Test #7:
score: 0
Accepted
time: 1ms
memory: 4008kb
input:
7
output:
YES 4 6 5 7 2 3 1
result:
ok answer is 1
Test #8:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
8
output:
NO
result:
ok answer is 0
Test #9:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
9
output:
NO
result:
ok answer is 0
Test #10:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
10
output:
NO
result:
ok answer is 0
Test #11:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
11
output:
NO
result:
ok answer is 0
Test #12:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
12
output:
NO
result:
ok answer is 0
Test #13:
score: -100
Wrong Answer
time: 1ms
memory: 3908kb
input:
13
output:
YES 8 12 9 11 10 13 4 5 7 6 2 3 1
result:
wrong answer Participant's answer is incorrect