QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#305129 | #8004. Bit Component | ucup-team266# | WA | 1ms | 3440kb | C++14 | 2.5kb | 2024-01-14 18:50:18 | 2024-01-14 18:50:18 |
Judging History
answer
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef array<int, 3> ai3;
const ll inf = 0x3f3f3f3f3f3f3f3fll;
const int Mod = 998244353;
inline int sign(int a){ return (a&1) ? (Mod-1) : 1; }
inline void uadd(int &a, int b){ a += b-Mod; a += (a>>31) & Mod; }
inline void usub(int &a, int b){ a -= b, a += (a>>31) & Mod; }
inline void umul(int &a, int b){ a = (int)(1ll * a * b % Mod); }
inline int add(int a, int b){ a += b-Mod; a += (a>>31) & Mod; return a; }
inline int sub(int a, int b){ a -= b, a += (a>>31) & Mod; return a; }
inline int mul(int a, int b){ a = (int)(1ll * a * b % Mod); return a; }
int qpow(int b, ll p){ int ret = 1; while(p){ if(p&1) umul(ret, b); umul(b, b), p >>= 1; } return ret; }
const int fN = 100;
int fact[fN], invfact[fN], pw2[fN], invpw2[fN], inv[fN];
void initfact(int n){
pw2[0] = 1; for(int i = 1; i <= n; ++i) pw2[i] = mul(pw2[i-1], 2);
invpw2[0] = 1; for(int i = 1; i <= n; ++i) invpw2[i] = mul(invpw2[i-1], (Mod+1) / 2);
fact[0] = 1; for(int i = 1; i <= n; ++i) fact[i] = mul(fact[i-1], i);
invfact[n] = qpow(fact[n], Mod-2); for(int i = n; i > 0; --i) invfact[i-1] = mul(invfact[i], i);
for(int i = 1; i <= n; ++i) inv[i] = mul(invfact[i], fact[i-1]);
}
int binom(int n, int m){ return (m < 0 || m > n) ? 0 : mul(fact[n], mul(invfact[m], invfact[n-m])); }
const double pi = acos(-1);
inline void chmax(ll &a, ll b){ (b>a) ? (a=b) : 0; }
inline void chmin(ll &a, ll b){ (b<a) ? (a=b) : 0; }
vi solve(int k){
if(k == 1)
return (vi){0, 1};
vi ret = solve(k-1);
int len = (int)ret.size();
rep(i, len)
ret.push_back((1<<(k-1)) | ret[len-i-1]);
return ret;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
int k = 0;
while(1<<k <= n) ++k;
if(n != (1<<k) - 1 && n != (1<<k) - 2) return cout << "NO\n", 0;
vi ret = solve(k);
cout << "YES\n";
if(n == (1<<k) - 1){
for(int i = 1; i < (int)ret.size(); ++i)
cout << ret[i] << ((i == (int)ret.size() - 1) ? '\n' : ' ');
} else if(n >= 8){
int ip = 0;
while(ret[ip] != n+1) ++ip;
for(int i = ip+1; i < (int)ret.size() - 1; ++i)
cout << ret[i] << " ";
for(int i = 1; i < (1<<(k-1)); ++i)
cout << ret[i] << " ";
for(int i = (1<<(k-1)); i < ip; ++i)
cout << ret[i] << " ";
cout << ret[(int)ret.size() - 1] << "\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3440kb
input:
1
output:
YES 1
result:
ok answer is 1
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3436kb
input:
2
output:
YES
result:
wrong output format Unexpected end of file - int32 expected