Submission #1068009

# Submission time Handle Problem Language Result Execution time Memory
1068009 2024-08-21T06:39:09 Z 김은성(#11126) NoM (RMI21_nom) C++17
9 / 100
1 ms 1628 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;
			}
			//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 348 KB Output is correct
2 Correct 0 ms 448 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 444 KB Output is correct
6 Correct 0 ms 348 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 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 448 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 444 KB Output is correct
6 Correct 0 ms 348 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 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 1628 KB Output is correct
12 Correct 0 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 Incorrect 1 ms 1116 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 448 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 444 KB Output is correct
6 Correct 0 ms 348 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 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 1628 KB Output is correct
12 Correct 0 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 Incorrect 1 ms 1116 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 448 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 444 KB Output is correct
6 Correct 0 ms 348 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 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 1628 KB Output is correct
12 Correct 0 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 Incorrect 1 ms 1116 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 448 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 444 KB Output is correct
6 Correct 0 ms 348 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 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 1628 KB Output is correct
12 Correct 0 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 Incorrect 1 ms 1116 KB Output isn't correct
17 Halted 0 ms 0 KB -