QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#273479#7875. Queue Sortingucup-team484#WA 0ms5584kbC++171.1kb2023-12-03 00:14:342023-12-03 00:14:35

Judging History

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

  • [2023-12-03 00:14:35]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:5584kb
  • [2023-12-03 00:14:34]
  • 提交

answer

#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define st first
#define nd second
using namespace std;
typedef long long ll;
const int mod = 998244353;
const int N = 1e3 + 5;
int fac[N], ifac[N], inv[N];
int dp[N][N];

void add(int& x, int y) {
	x += y;
	if (x >= mod)
		x -= mod;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	fac[0] = ifac[0] = fac[1] = ifac[1] = inv[1] = 1;
	for (int i = 2; i < N; i++) {
		inv[i] = mod - (mod / i) * 1ll * inv[mod % i] % mod;
		fac[i] = fac[i - 1] * 1ll * i % mod;
		ifac[i] = ifac[i - 1] * 1ll * inv[i] % mod;
	}
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	dp[0][0] = 1;
	int s = 0;
	for (int i = 0; i < n; i++) if (a[i] != 0) {
		for (int x = s, y = 0; x >= y; x--, y++) {
			for (int j = a[i]; j >= 0 && x + j >= y + a[i] - j; j--) {
				if (y + a[i] - j <= x)
					add(dp[x + j][y + a[i] - j], dp[x][y]);
			}
		}
		s += a[i];
	}
	int ans = 0;
	for (int i = 0; 2 * i <= s; i++) {
		int val = dp[s - i][i];
		ans = (ans + val * 1ll * val) % mod;
	}
	cout << ans << "\n";
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3584kb

input:

4
1 1 1 1

output:

14

result:

ok 1 number(s): "14"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 5584kb

input:

300
0 5 2 2 1 0 3 2 2 5 2 1 1 2 1 3 2 3 2 0 0 0 0 1 2 2 3 0 2 2 3 2 0 2 3 0 6 0 0 2 0 1 3 2 1 1 1 3 4 0 1 0 4 1 1 1 1 1 1 2 3 2 1 2 3 2 3 0 5 3 3 2 0 1 1 0 2 1 1 2 0 0 2 1 1 3 2 2 1 2 1 3 0 3 0 1 2 2 0 5 0 2 2 0 0 0 1 2 1 4 2 1 1 0 3 0 2 0 3 1 1 2 0 2 1 1 0 2 0 1 2 2 3 3 1 1 1 1 0 1 3 3 1 0 2 2 4 2 ...

output:

585712073

result:

wrong answer 1st numbers differ - expected: '507010274', found: '585712073'