Submission #1068017

# Submission time Handle Problem Language Result Execution time Memory
1068017 2024-08-21T06:41:19 Z 김은성(#11126) NoM (RMI21_nom) C++17
100 / 100
69 ms 93960 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1'000'000'007;
ll dp[2009][2009], c[4009][4009], fact[4009];
int a[2009], ssum[2009];
int main(){
	int n, m, i, j, k;
	ll mul = 1, ans = 0;
	scanf("%d %d", &n, &m);
	if(m==1){
		printf("0\n");
		return 0;
	}
	for(i=1; i<=n; i++)
		mul = (mul*2)%mod;
	for(i=1; i<=(2*n)%m; i++)
		a[i] = 2*n/m+1;
	for(i=(2*n)%m+1; i<=m; i++)
		a[i] = 2*n/m;
	int crit = m;
	dp[0][n] = 1;
	ssum[crit+1] = 0;
	for(i=crit; i>=1; i--)
		ssum[i] = ssum[i+1] + a[i];
	c[0][0] = 1;
	for(i=1; i<=2*n; i++){
		c[i][0] = c[i][i] = 1;
		for(j=1; j<i; j++)
			c[i][j] = (c[i-1][j] + c[i-1][j-1]) % mod;
	}
	fact[0] = 1;
	for(i=1; i<=2*n; i++)
		fact[i] = fact[i-1] * i % mod;
	for(i=1; i<=crit; i++){
		//printf("i=%d a[i]=%lld\n", i, a[i]);
		for(j=max(ssum[i+1] - n, 0); j<=ssum[i+1]/2; j++){
			for(k=0; k<=a[i]; k++){
				if(ssum[i] - 2*(j+k) < 0)
					continue;
				dp[i][j] += (dp[i-1][j+k] * c[j+k][k])%mod * c[ssum[i] - 2*(j+k)][a[i]-k]%mod * fact[a[i]] % mod;
			}
			dp[i][j] %= mod;
			//printf("dp[%d][%d]=%lld\n", i, j, dp[i][j]);
		}
	}
	printf("%lld\n", (dp[crit][0]*mul)%mod);
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:9:14: warning: unused variable 'ans' [-Wunused-variable]
    9 |  ll mul = 1, ans = 0;
      |              ^~~
Main.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  scanf("%d %d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 1628 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 860 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1372 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 1 ms 1116 KB Output is correct
18 Correct 1 ms 1248 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 1628 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 860 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1372 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 1 ms 1116 KB Output is correct
18 Correct 1 ms 1248 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 2 ms 2140 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 3 ms 4700 KB Output is correct
23 Correct 3 ms 3164 KB Output is correct
24 Correct 3 ms 4700 KB Output is correct
25 Correct 3 ms 4700 KB Output is correct
26 Correct 2 ms 3520 KB Output is correct
27 Correct 3 ms 5468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 1628 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 860 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1372 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 1 ms 1116 KB Output is correct
18 Correct 1 ms 1248 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 2 ms 2140 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 3 ms 4700 KB Output is correct
23 Correct 3 ms 3164 KB Output is correct
24 Correct 3 ms 4700 KB Output is correct
25 Correct 3 ms 4700 KB Output is correct
26 Correct 2 ms 3520 KB Output is correct
27 Correct 3 ms 5468 KB Output is correct
28 Correct 7 ms 11608 KB Output is correct
29 Correct 11 ms 14172 KB Output is correct
30 Correct 14 ms 15308 KB Output is correct
31 Correct 8 ms 11864 KB Output is correct
32 Correct 13 ms 15196 KB Output is correct
33 Correct 11 ms 17756 KB Output is correct
34 Correct 15 ms 25436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 1628 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 860 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1372 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 1 ms 1116 KB Output is correct
18 Correct 1 ms 1248 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 2 ms 2140 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 3 ms 4700 KB Output is correct
23 Correct 3 ms 3164 KB Output is correct
24 Correct 3 ms 4700 KB Output is correct
25 Correct 3 ms 4700 KB Output is correct
26 Correct 2 ms 3520 KB Output is correct
27 Correct 3 ms 5468 KB Output is correct
28 Correct 7 ms 11608 KB Output is correct
29 Correct 11 ms 14172 KB Output is correct
30 Correct 14 ms 15308 KB Output is correct
31 Correct 8 ms 11864 KB Output is correct
32 Correct 13 ms 15196 KB Output is correct
33 Correct 11 ms 17756 KB Output is correct
34 Correct 15 ms 25436 KB Output is correct
35 Correct 41 ms 54876 KB Output is correct
36 Correct 57 ms 77068 KB Output is correct
37 Correct 31 ms 53592 KB Output is correct
38 Correct 52 ms 62348 KB Output is correct
39 Correct 41 ms 63056 KB Output is correct
40 Correct 69 ms 93960 KB Output is correct