QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#304547 | #8004. Bit Component | ucup-team1303# | WA | 0ms | 3788kb | C++20 | 1.9kb | 2024-01-13 20:59:14 | 2024-01-13 20:59:15 |
Judging History
answer
// MagicDark
#include <bits/stdc++.h>
#define debug cerr << "[" << __LINE__ << "] "
#define SZ(x) (int) x.size() - 1
#define all(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x)
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define DF(i, x, y) for (int i = (x); i >= (y); i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> inline void chkmax(T& x, T y) {x = max(x, y);}
template <typename T> inline void chkmin(T& x, T y) {x = min(x, y);}
template <typename T> inline void read(T &x) {
x = 0; int f = 1; char c = getchar();
for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
x *= f;
}
vector <int> t;
void work(int n) {
t.clear();
t.push_back(1);
while (t.size() < n) {
vector <int> tt;
int g = t.size();
for (int i: t) tt.push_back(i);
reverse(all(t));
for (int i: t) tt.push_back(i + g + 1);
tt.push_back(g + 1);
swap(t, tt);
}
}
signed main() {
int n; cin >> n;
if (n == 1) {
puts("YES\n1");
return 0;
}
if (n == 3) {
puts("YES\n1 3 2");
return 0;
}
int w = 31 ^ __builtin_clz(n);
if (!(n & (1 << (w - 1))) || (n == ((1 << w) | (1 << (w - 1))))) {
puts("NO");
return 0;
}
puts("YES");
work((1 << w) - 1);
vector <int> ans;
// ans.erase(find(all(ans), 1 << (w - 1)));
for (int i: t) {
if (i == (1 << (w - 1))) continue;
ans.push_back(i);
if (i & (1 << (w - 1))) {
int ii = i + (1 << w);
if (ii <= n) ans.push_back(ii);
}
}
// for (int i: ans) cout << i << " "; cout << endl;
ans.push_back((1 << w) + (1 << (w - 1)));
work((1 << (w - 1)) - 1);
for (int i: t) ans.push_back(i | (1 << w));
ans.push_back((1 << w));
ans.push_back((1 << w) | (1 << (w - 1)));
ans.push_back((1 << (w - 1)));
for (int i: ans) cout << i << " ";
// ans.push_back();
return 0;
}
/* why?
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3788kb
input:
1
output:
YES 1
result:
ok answer is 1
Test #2:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
2
output:
NO
result:
ok answer is 0
Test #3:
score: 0
Accepted
time: 0ms
memory: 3560kb
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: 3564kb
input:
5
output:
NO
result:
ok answer is 0
Test #6:
score: 0
Accepted
time: 0ms
memory: 3744kb
input:
6
output:
NO
result:
ok answer is 0
Test #7:
score: -100
Wrong Answer
time: 0ms
memory: 3500kb
input:
7
output:
YES 1 3 7 6 5 4 6 2
result:
wrong answer Every number must appear exactly once, but 2 appears 0 times