Submission #796646

# Submission time Handle Problem Language Result Execution time Memory
796646 2023-07-28T15:15:18 Z rainboy NoM (RMI21_nom) C
52 / 100
500 ms 468 KB
#include <stdio.h>

#define N	2000
#define MD	1000000007

int pp2[N * 2 + 1], vv[N * 2 + 1], ff[N * 2 + 1], gg[N * 2 + 1];

void init() {
	int i;

	pp2[0] = ff[0] = gg[0] = 1;
	for (i = 1; i <= N * 2; i++) {
		pp2[i] = pp2[i - 1] * 2 % MD;
		vv[i] = i == 1 ? 1 : (long long) vv[i - MD % i] * (MD / i + 1) % MD;
		ff[i] = (long long) ff[i - 1] * i % MD;
		gg[i] = (long long) gg[i - 1] * vv[i] % MD;
	}
}

int choose(int n, int k) {
	return (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;
}

int main() {
	static int dp[N + 1];
	int n, n_, m, r, k1, k2, l, l1, l2, x;

	init();
	scanf("%d%d", &n, &m);
	n_ = n * 2;
	dp[n] = 1;
	for (r = 0; r < m; r++) {
		l = (n * 2 + m - 1 - r) / m;
		for (k2 = 0; k2 * 2 <= n_; k2++) {
			k1 = n_ - k2 * 2, x = dp[k2];
			if (x == 0)
				continue;
			dp[k2] = 0;
			for (l2 = 0; l2 <= k2; l2++) {
				l1 = l - l2;
				if (l1 >= 0 && l1 <= k1)
					dp[k2 - l2] = (dp[k2 - l2] + (long long) x * choose(k1, l1) % MD * choose(k2, l2) % MD * pp2[l2] % MD * ff[l]) % MD;
			}
		}
		n_ -= l;
	}
	printf("%d\n", dp[0]);
	return 0;
}

Compilation message

Main.c: In function 'main':
Main.c:29:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |  scanf("%d%d", &n, &m);
      |  ^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 352 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 352 KB Output is correct
9 Correct 0 ms 352 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 352 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 352 KB Output is correct
9 Correct 0 ms 352 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 352 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 352 KB Output is correct
9 Correct 0 ms 352 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 3 ms 340 KB Output is correct
23 Correct 1 ms 352 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 4 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 352 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 352 KB Output is correct
9 Correct 0 ms 352 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 3 ms 340 KB Output is correct
23 Correct 1 ms 352 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 4 ms 340 KB Output is correct
28 Correct 3 ms 340 KB Output is correct
29 Correct 16 ms 468 KB Output is correct
30 Correct 25 ms 352 KB Output is correct
31 Correct 3 ms 340 KB Output is correct
32 Correct 17 ms 340 KB Output is correct
33 Correct 32 ms 340 KB Output is correct
34 Correct 78 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 352 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 352 KB Output is correct
9 Correct 0 ms 352 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 3 ms 340 KB Output is correct
23 Correct 1 ms 352 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 4 ms 340 KB Output is correct
28 Correct 3 ms 340 KB Output is correct
29 Correct 16 ms 468 KB Output is correct
30 Correct 25 ms 352 KB Output is correct
31 Correct 3 ms 340 KB Output is correct
32 Correct 17 ms 340 KB Output is correct
33 Correct 32 ms 340 KB Output is correct
34 Correct 78 ms 340 KB Output is correct
35 Correct 19 ms 340 KB Output is correct
36 Correct 459 ms 340 KB Output is correct
37 Correct 18 ms 340 KB Output is correct
38 Correct 206 ms 352 KB Output is correct
39 Correct 400 ms 340 KB Output is correct
40 Execution timed out 679 ms 340 KB Time limit exceeded
41 Halted 0 ms 0 KB -