QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#305131#8004. Bit Componentucup-team266#WA 1ms3552kbC++142.5kb2024-01-14 18:51:302024-01-14 18:51:31

Judging History

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

  • [2024-01-14 18:51:31]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3552kb
  • [2024-01-14 18:51:30]
  • 提交

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);
	if(n == (1<<k) - 1){
		cout << "YES\n";
		for(int i = 1; i < (int)ret.size(); ++i)
			cout << ret[i] << ((i == (int)ret.size() - 1) ? '\n' : ' ');
	} else {
		if(n >= 8){
			cout << "YES\n";
			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";
		} else {
			cout << "NO\n";
		}
	}

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3544kb

input:

1

output:

YES
1

result:

ok answer is 1

Test #2:

score: 0
Accepted
time: 1ms
memory: 3428kb

input:

2

output:

NO

result:

ok answer is 0

Test #3:

score: 0
Accepted
time: 0ms
memory: 3424kb

input:

3

output:

YES
1 3 2

result:

ok answer is 1

Test #4:

score: 0
Accepted
time: 0ms
memory: 3428kb

input:

4

output:

NO

result:

ok answer is 0

Test #5:

score: 0
Accepted
time: 0ms
memory: 3428kb

input:

5

output:

NO

result:

ok answer is 0

Test #6:

score: 0
Accepted
time: 0ms
memory: 3484kb

input:

6

output:

NO

result:

ok answer is 0

Test #7:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

7

output:

YES
1 3 2 6 7 5 4

result:

ok answer is 1

Test #8:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

8

output:

NO

result:

ok answer is 0

Test #9:

score: 0
Accepted
time: 0ms
memory: 3492kb

input:

9

output:

NO

result:

ok answer is 0

Test #10:

score: 0
Accepted
time: 1ms
memory: 3484kb

input:

10

output:

NO

result:

ok answer is 0

Test #11:

score: 0
Accepted
time: 0ms
memory: 3476kb

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: 3428kb

input:

13

output:

NO

result:

wrong answer Jury has the answer, participant doesn't