QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#304926 | #8004. Bit Component | ucup-team992# | WA | 0ms | 3820kb | C++17 | 1.8kb | 2024-01-14 06:30:40 | 2024-01-14 06:30:40 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef int uci;
#define int long long
#define F first
#define S second
#define ar array
void solve(){
int n;
cin >> n;
if(n == 1) {
cout << "YES\n1\n"; return;
}
if(n == 3) {
cout << "YES\n1 3 2\n"; return;
}
if(n == 7) {
cout << "YES\n4 5 7 6 2 3 1\n"; return;
}
int mg = 1;
while(n >= (1 << mg)) mg++;
mg--;
if(n >> (mg - 2) != 0b111) {
cout << "NO\n";
return;
}
vector<int> v;
v.push_back(1);
for(int i{2}; i <= mg-2; ++i){
vector<int> ne;
ne.push_back(1<<(i-1));
for(int j = v.size()-1; j >= 0; --j){
ne.push_back((1<<(i-1)) | v[j]);
}
for(int i : v)
ne.push_back(i);
v.swap(ne);
}
v.insert(v.begin(),0LL);
vector<int> res;
int shft = mg - 2;
for(auto x: v) res.push_back((0b101 << shft) | x);
bool f = false;
for(auto x: v) {
int hi = (0b111 << shft) | x;
if(hi <= n) res.push_back((0b111 << shft) | x);
vector<int> seq = {1,3,2,6,4};
if(f) reverse(seq.begin(), seq.end());
f = !f;
for(auto s: seq) res.push_back((s << shft) | x);
}
reverse(v.begin(), v.end());
for(auto x: v) if(x) res.push_back(x);
/*cout << "DBG\n";
for(auto x: res) {
bitset<10> b(x);
cout << b << endl;
}*/
//set<int> S;
//for(auto x: res) S.insert(x);
//cout << S.size() << endl;
cout << "YES\n";
for(int i : res)
cout << i << ' ';
cout << '\n';
}
uci main(){
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3612kb
input:
1
output:
YES 1
result:
ok answer is 1
Test #2:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
2
output:
NO
result:
ok answer is 0
Test #3:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
3
output:
YES 1 3 2
result:
ok answer is 1
Test #4:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
4
output:
NO
result:
ok answer is 0
Test #5:
score: 0
Accepted
time: 0ms
memory: 3560kb
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: 3548kb
input:
7
output:
YES 4 5 7 6 2 3 1
result:
ok answer is 1
Test #8:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
8
output:
NO
result:
ok answer is 0
Test #9:
score: 0
Accepted
time: 0ms
memory: 3764kb
input:
9
output:
NO
result:
ok answer is 0
Test #10:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
10
output:
NO
result:
ok answer is 0
Test #11:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
11
output:
NO
result:
ok answer is 0
Test #12:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
12
output:
NO
result:
ok answer is 0
Test #13:
score: -100
Wrong Answer
time: 0ms
memory: 3624kb
input:
13
output:
NO
result:
wrong answer Jury has the answer, participant doesn't