QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#273477#7875. Queue Sortingucup-team484#WA 2ms5444kbC++171.1kb2023-12-03 00:14:032023-12-03 00:14:04

Judging History

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

  • [2023-12-03 00:14:04]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:5444kb
  • [2023-12-03 00:14:03]
  • 提交

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 = 1e9 + 7;
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: 3508kb

input:

4
1 1 1 1

output:

14

result:

ok 1 number(s): "14"

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 5444kb

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:

883780650

result:

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