QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#305129#8004. Bit Componentucup-team266#WA 1ms3440kbC++142.5kb2024-01-14 18:50:182024-01-14 18:50:18

Judging History

你现在查看的是最新测评结果

  • [2024-01-14 18:50:18]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3440kb
  • [2024-01-14 18:50:18]
  • 提交

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