# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
54663 |
2018-07-04T11:37:52 Z |
dennisstar |
Tents (JOI18_tents) |
C++11 |
|
5 ms |
2724 KB |
#include <bits/stdc++.h>
#define MOD 1000000007
int H, W;
long long Dp[3010][3010];
int main()
{
scanf("%d%d", &H, &W);
int i, j;
for (i=0; i<=H; i++) Dp[i][0]=1;
for (i=0; i<=W; i++) Dp[0][i]=1;
for (i=1; i<=H; i++) Dp[i][1]=4*i+i*(i-1)/2+1;
for (j=1; j<=W; j++) Dp[1][j]=4*j+j*(j-1)/2+1;
for (i=2; i<=H; i++) {
for(j=2; j<=W; j++) {
Dp[i][j]=Dp[i-1][j-1]*5;
Dp[i][j]+=Dp[i-1][j-2]*(j-1)*5+Dp[i-2][j-1]*(i-1)*5; //1,0 0,1
Dp[i][j]+=Dp[i-2][j-2]*(j-1)*(i-1)*2; //1,0 0,1
if (i>=3) Dp[i][j]+=Dp[i-3][j-1]*(i-1)*(i-2)/2; //2,0
if (j>=3) Dp[i][j]+=Dp[i-1][j-3]*(j-1)*(j-2)/2; //0,2
Dp[i][j]+=Dp[i-2][j-2]*16*(i-1)*(j-1); //1,1
if (i>=3) Dp[i][j]+=Dp[i-3][j-2]*(i-1)*(j-1)*(i-2)*4; //1,1
if (j>=3) Dp[i][j]+=Dp[i-2][j-3]*(j-1)*(i-1)*(j-2)*4; //1,1
if (i>=3&&j>=3) Dp[i][j]+=Dp[i-3][j-3]*((i-1)*(j-1)*(i-2)*(j-2)%MOD); //1,1
if (i>=3) Dp[i][j]+=Dp[i-3][j-2]*(i-1)*(i-2)*(j-1)*2; //2,1
if (i>=4) Dp[i][j]+=Dp[i-4][j-2]*((i-1)*(i-2)/2*(j-1)*(i-3)%MOD); //2,1
if (j>=3) Dp[i][j]+=Dp[i-2][j-3]*(j-1)*(j-2)*(i-1)*2; //1,2
if (j>=4) Dp[i][j]+=Dp[i-2][j-4]*((j-1)*(j-2)/2*(i-1)*(j-3)%MOD); //1,2
if (i>=3&&j>=3) Dp[i][j]+=Dp[i-3][j-3]*((i-1)*(j-1)*(i-2)*(j-2)/4%MOD); //2,2
Dp[i][j]%=MOD;
}
}
printf("%d", Dp[H][W]-1);
return 0;
}
Compilation message
tents.cpp: In function 'int main()':
tents.cpp:32:25: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
printf("%d", Dp[H][W]-1);
~~~~~~~~~~^
tents.cpp:7:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &H, &W);
~~~~~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
472 KB |
Output is correct |
3 |
Correct |
2 ms |
740 KB |
Output is correct |
4 |
Correct |
3 ms |
1348 KB |
Output is correct |
5 |
Correct |
4 ms |
1348 KB |
Output is correct |
6 |
Correct |
4 ms |
1660 KB |
Output is correct |
7 |
Correct |
3 ms |
1660 KB |
Output is correct |
8 |
Correct |
3 ms |
1800 KB |
Output is correct |
9 |
Correct |
3 ms |
1800 KB |
Output is correct |
10 |
Correct |
5 ms |
2076 KB |
Output is correct |
11 |
Correct |
2 ms |
2076 KB |
Output is correct |
12 |
Incorrect |
5 ms |
2724 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
472 KB |
Output is correct |
3 |
Correct |
2 ms |
740 KB |
Output is correct |
4 |
Correct |
3 ms |
1348 KB |
Output is correct |
5 |
Correct |
4 ms |
1348 KB |
Output is correct |
6 |
Correct |
4 ms |
1660 KB |
Output is correct |
7 |
Correct |
3 ms |
1660 KB |
Output is correct |
8 |
Correct |
3 ms |
1800 KB |
Output is correct |
9 |
Correct |
3 ms |
1800 KB |
Output is correct |
10 |
Correct |
5 ms |
2076 KB |
Output is correct |
11 |
Correct |
2 ms |
2076 KB |
Output is correct |
12 |
Incorrect |
5 ms |
2724 KB |
Output isn't correct |