Submission #68617

# Submission time Handle Problem Language Result Execution time Memory
68617 2018-08-17T14:34:40 Z TadijaSebez Tents (JOI18_tents) C++11
100 / 100
218 ms 36004 KB
#include <stdio.h>
#define ll long long
const int N=3005;
const int mod=1e9+7;
int dp[N][N];
int main()
{
	int n,m,i,j;
	scanf("%i %i",&n,&m);
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=m;j++)
		{
			if(i==0 || j==0){ dp[i][j]=1;continue;}
			dp[i][j]=dp[i-1][j]+(ll)dp[i-1][j-1]*j%mod*4%mod;
			dp[i][j]%=mod;
			if(i>1) dp[i][j]+=(ll)dp[i-2][j-1]*j%mod*(i-1)%mod;
			dp[i][j]%=mod;
			if(j>1) dp[i][j]+=(ll)dp[i-1][j-2]*((ll)j*(j-1)/2%mod)%mod;
			dp[i][j]%=mod;
		}
	}
	printf("%i\n",(dp[n][m]+mod-1)%mod);
	return 0;
}

Compilation message

tents.cpp: In function 'int main()':
tents.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i %i",&n,&m);
  ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 728 KB Output is correct
4 Correct 3 ms 1412 KB Output is correct
5 Correct 3 ms 1412 KB Output is correct
6 Correct 4 ms 1488 KB Output is correct
7 Correct 3 ms 1488 KB Output is correct
8 Correct 5 ms 1668 KB Output is correct
9 Correct 3 ms 1668 KB Output is correct
10 Correct 4 ms 1932 KB Output is correct
11 Correct 2 ms 1932 KB Output is correct
12 Correct 5 ms 2068 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 728 KB Output is correct
4 Correct 3 ms 1412 KB Output is correct
5 Correct 3 ms 1412 KB Output is correct
6 Correct 4 ms 1488 KB Output is correct
7 Correct 3 ms 1488 KB Output is correct
8 Correct 5 ms 1668 KB Output is correct
9 Correct 3 ms 1668 KB Output is correct
10 Correct 4 ms 1932 KB Output is correct
11 Correct 2 ms 1932 KB Output is correct
12 Correct 5 ms 2068 KB Output is correct
13 Correct 2 ms 2068 KB Output is correct
14 Correct 9 ms 9884 KB Output is correct
15 Correct 143 ms 33108 KB Output is correct
16 Correct 12 ms 33108 KB Output is correct
17 Correct 32 ms 33108 KB Output is correct
18 Correct 45 ms 33108 KB Output is correct
19 Correct 175 ms 34968 KB Output is correct
20 Correct 151 ms 34968 KB Output is correct
21 Correct 95 ms 34968 KB Output is correct
22 Correct 96 ms 34968 KB Output is correct
23 Correct 64 ms 34968 KB Output is correct
24 Correct 218 ms 36004 KB Output is correct
25 Correct 213 ms 36004 KB Output is correct
26 Correct 179 ms 36004 KB Output is correct
27 Correct 205 ms 36004 KB Output is correct