QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#266385#3542. Very Simple SumkyEEccccccWA 1779ms8076kbC++141.5kb2023-11-26 13:35:522023-11-26 13:35:52

Judging History

This is the latest submission verdict.

  • [2023-11-26 13:35:52]
  • Judged
  • Verdict: WA
  • Time: 1779ms
  • Memory: 8076kb
  • [2023-11-26 13:35:52]
  • Submitted

answer

// Author: kyEEcccccc

#include <bits/stdc++.h>

using namespace std;

using LL = long long;
using ULL = unsigned long long;

#define F(i, l, r) for (int i = (l); i <= (r); ++i)
#define FF(i, r, l) for (int i = (r); i >= (l); --i)
#define MAX(a, b) ((a) = max(a, b))
#define MIN(a, b) ((a) = min(a, b))
#define SZ(a) ((int)((a).size()) - 1)

constexpr int N = 100005, M = 512, MOD = 998244353;

LL kpow(LL x, LL k = MOD - 2)
{
	x %= MOD;
	LL r = 1;
	while (k)
	{
		if (k & 1) r = r * x % MOD;
		x = x * x % MOD;
		k >>= 1;
	}
	return r;
}

int n;
int a[N], b[N];
LL sum[M][M];
LL fac[M], ifac[M];
LL f[M][M];
bool ok[M];

signed main(void)
{
	// freopen(".in", "r", stdin);
	// freopen(".out", "w", stdout);
	ios::sync_with_stdio(0), cin.tie(nullptr);

	cin >> n;
	F(i, 1, n) cin >> a[i];
	F(i, 1, n) cin >> b[i];

	fac[0] = 1;
	F(i, 1, M - 1) fac[i] = fac[i - 1] * i % MOD;
	ifac[M - 1] = kpow(fac[M - 1]);
	FF(i, M - 1, 1) ifac[i - 1] = ifac[i] * i % MOD;

	F(i, 1, n)
	{
		sum[b[i]][0] += 1;
		ok[b[i]] = true;
		LL cur = 1;
		F(j, 1, M - 1)
		{
			(cur *= a[i]) %= MOD;
			sum[b[i]][j] += cur;
		}
	}

	F(i, 0, M - 1)
	{
		if (!ok[i]) continue;
		F(j, 0, M - 1)
		{
			if (!ok[j]) continue;
			F(k, 0, M - 1) F(l, 0, M - 1 - k)
				(f[i ^ j][k + l] += sum[i][k] * sum[j][l] % MOD * ifac[k] % MOD * ifac[l]) %= MOD;
		}
	}
	LL ans = 0;
	F(i, 0, M - 1) F(j, 0, M - 1) F(k, 0, i ^ j)
		(ans += f[i][k] * f[j][(i ^ j) - k] % MOD * fac[i ^ j]) %= MOD;
	cout << ans << endl;
	
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 218ms
memory: 5384kb

input:

1
1
1

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 234ms
memory: 7480kb

input:

5
227 67 445 67 213
297 171 324 493 354

output:

42

result:

ok 1 number(s): "42"

Test #3:

score: 0
Accepted
time: 343ms
memory: 5912kb

input:

20
93 84 58 43 46 90 86 67 86 1 20 69 91 49 5 97 81 61 81 42
60 73 35 61 94 88 53 52 66 3 5 32 14 48 10 32 86 72 52 32

output:

36313816

result:

ok 1 number(s): "36313816"

Test #4:

score: 0
Accepted
time: 345ms
memory: 8076kb

input:

20
17 24 8 24 99 67 57 51 46 87 63 8 85 83 20 10 95 23 99 83
1 51 48 36 51 97 70 13 79 69 35 15 1 84 23 44 16 35 85 42

output:

357580675

result:

ok 1 number(s): "357580675"

Test #5:

score: 0
Accepted
time: 374ms
memory: 5892kb

input:

20
41 72 62 98 49 32 45 39 1 70 3 52 76 20 43 27 22 70 18 28
53 29 58 15 12 5 95 74 99 40 49 85 100 17 28 44 49 10 23 57

output:

173357999

result:

ok 1 number(s): "173357999"

Test #6:

score: 0
Accepted
time: 370ms
memory: 7772kb

input:

20
69 13 15 72 10 13 28 31 57 48 42 4 62 57 66 44 36 32 40 77
2 15 67 99 69 29 16 27 11 10 75 59 91 49 33 48 79 85 64 64

output:

649835489

result:

ok 1 number(s): "649835489"

Test #7:

score: 0
Accepted
time: 360ms
memory: 5908kb

input:

20
97 65 65 49 64 90 3 15 12 34 90 47 56 94 81 61 63 90 62 21
42 92 76 82 30 37 33 88 20 76 1 30 78 81 41 53 9 55 2 74

output:

304078125

result:

ok 1 number(s): "304078125"

Test #8:

score: -100
Wrong Answer
time: 1779ms
memory: 7912kb

input:

100
16 97 48 43 62 18 55 65 37 3 49 84 31 35 20 87 65 4 42 24 77 66 61 70 85 2 1 64 66 4 17 75 47 53 10 40 63 77 94 75 86 90 78 97 72 71 49 63 100 42 55 61 91 63 91 88 7 11 25 76 8 13 80 3 86 32 37 28 73 40 59 33 44 4 53 61 23 62 27 3 21 43 69 5 46 39 94 5 57 86 82 92 35 26 81 6 15 55 30 19
33 13 4 ...

output:

92744025

result:

wrong answer 1st numbers differ - expected: '391854458', found: '92744025'