QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#307465 | #8004. Bit Component | ucup_team_qiuly# | WA | 0ms | 3832kb | C++14 | 1.6kb | 2024-01-18 17:03:39 | 2024-01-18 17:03:40 |
Judging History
answer
//
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(...) fprintf (stderr, __VA_ARGS__)
#define lep(i, l, r) for (int i = (l), i##_end = (r); i <= i##_end; ++ i)
#define rep(i, r, l) for (int i = (r), i##_end = (l); i >= i##_end; -- i)
char _c; bool _f; template <class T> inline void IN (T & x) {
_f = 0, x = 0; while (_c = getchar (), ! isdigit (_c)) if (_c == '-') _f = 1;
while (isdigit (_c)) x = x * 10 + _c - '0', _c = getchar (); if (_f) x = - x;
}
signed main () {
int n; IN (n);
if (n == 1) return printf ("YES\n1\n"), 0;
if (n == 3) return printf ("YES\n2 3 1\n"), 0;
vector <int> ans (n + 1);
int m = 0; for ( ; (1 << m) <= n; ++ m);
auto bit = [&] (int x, int b) { return (x >> b) & 1; };
int p = 1 << m - 1;
int q = p + (1 << m - 2);
if (n < q + 1) return puts ("NO"), 0;
{ // [1, p - 1]
vector <int> s (1, 0);
lep (t, 1, m - 1) {
vector <int> _s;
lep (i, 0, (1 << t - 1) - 1) _s.emplace_back ( s[i] << 1 );
rep (i, (1 << t - 1) - 1, 0) _s.emplace_back ( (s[i] << 1) | 1);
swap (s, _s);
}
lep (i, 1, p - 1) ans[i] = s[i];
}
int x = p;
{
vector <int> s (1, 0);
lep (t, 1, m - 2) {
vector <int> _s;
lep (i, 0, (1 << t - 1) - 1) _s.emplace_back ( s[i] );
rep (i, (1 << t - 1) - 1, 0) _s.emplace_back ( s[i] | (1 << t - 1) );
swap (s, _s);
}
lep (i, 1, q - p - 1) {
ans[x ++ ] = s[i] | p;
if ((s[i] | q) <= n) ans[x ++ ] = s[i] | q;
}
}
ans[x ++ ] = p, ans[x ++ ] = q;
puts ("YES");
lep (i, 1, n) printf ("%d%c", ans[i], " \n"[i == n]);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3832kb
input:
1
output:
YES 1
result:
ok answer is 1
Test #2:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
2
output:
NO
result:
ok answer is 0
Test #3:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
3
output:
YES 2 3 1
result:
ok answer is 1
Test #4:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
4
output:
NO
result:
ok answer is 0
Test #5:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
5
output:
NO
result:
ok answer is 0
Test #6:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
6
output:
NO
result:
ok answer is 0
Test #7:
score: 0
Accepted
time: 0ms
memory: 3752kb
input:
7
output:
YES 2 3 1 5 7 4 6
result:
ok answer is 1
Test #8:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
8
output:
NO
result:
ok answer is 0
Test #9:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
9
output:
NO
result:
ok answer is 0
Test #10:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
10
output:
NO
result:
ok answer is 0
Test #11:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
11
output:
NO
result:
ok answer is 0
Test #12:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
12
output:
NO
result:
ok answer is 0
Test #13:
score: -100
Wrong Answer
time: 0ms
memory: 3752kb
input:
13
output:
YES 4 6 2 3 7 5 1 9 13 11 10 8 12
result:
wrong answer Participant's answer is incorrect