Submission #54668

# Submission time Handle Problem Language Result Execution time Memory
54668 2018-07-04T11:48:30 Z dennisstar Tents (JOI18_tents) C++11
100 / 100
773 ms 71424 KB
#include <bits/stdc++.h>
#define MOD 1000000007
int H, W;
long long Dp[3010][3010];
int main()
{
	scanf("%d%d", &H, &W);
	long long 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%MOD; Dp[i][j]%=MOD;
			Dp[i][j]+=Dp[i-1][j-2]*(j-1)*5+Dp[i-2][j-1]*(i-1)*5%MOD; Dp[i][j]%=MOD;
			Dp[i][j]+=Dp[i-2][j-2]*(j-1)*(i-1)*2%MOD; Dp[i][j]%=MOD;
			if (i>=3) Dp[i][j]+=Dp[i-3][j-1]*(i-1)*(i-2)/2%MOD; Dp[i][j]%=MOD;
			if (j>=3) Dp[i][j]+=Dp[i-1][j-3]*(j-1)*(j-2)/2%MOD; Dp[i][j]%=MOD;
			Dp[i][j]+=Dp[i-2][j-2]*16*(i-1)*(j-1)%MOD; Dp[i][j]%=MOD;
			if (i>=3) Dp[i][j]+=Dp[i-3][j-2]*((i-1)*(j-1)*(i-2)*4%MOD)%MOD; Dp[i][j]%=MOD;
			if (j>=3) Dp[i][j]+=Dp[i-2][j-3]*((j-1)*(i-1)*(j-2)*4%MOD)%MOD; Dp[i][j]%=MOD;
			if (i>=3&&j>=3) Dp[i][j]+=(Dp[i-3][j-3]*((i-1)*(j-1)*(i-2)*(j-2)%MOD))%MOD; Dp[i][j]%=MOD;
			if (i>=3) Dp[i][j]+=Dp[i-3][j-2]*((i-1)*(i-2)*(j-1)*2%MOD)%MOD; Dp[i][j]%=MOD;
			if (i>=4) Dp[i][j]+=Dp[i-4][j-2]*(((i-1)*(i-2)/2*(j-1)*(i-3))%MOD)%MOD; Dp[i][j]%=MOD;
			if (j>=3) Dp[i][j]+=Dp[i-2][j-3]*((j-1)*(j-2)*(i-1)*2%MOD)%MOD; Dp[i][j]%=MOD;
			if (j>=4) Dp[i][j]+=Dp[i-2][j-4]*(((j-1)*(j-2)/2*(i-1)*(j-3))%MOD)%MOD; Dp[i][j]%=MOD;
			if (i>=3&&j>=3) Dp[i][j]+=(Dp[i-3][j-3]*(((i-1)*(j-1)*(i-2)*(j-2)/4)%MOD))%MOD; Dp[i][j]%=MOD;
		}
	}
	printf("%lld", Dp[H][W]-1);
	return 0;
}

Compilation message

tents.cpp: In function 'int main()':
tents.cpp:18:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    if (i>=3) Dp[i][j]+=Dp[i-3][j-1]*(i-1)*(i-2)/2%MOD; Dp[i][j]%=MOD;
    ^~
tents.cpp:18:56: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    if (i>=3) Dp[i][j]+=Dp[i-3][j-1]*(i-1)*(i-2)/2%MOD; Dp[i][j]%=MOD;
                                                        ^~
tents.cpp:19:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    if (j>=3) Dp[i][j]+=Dp[i-1][j-3]*(j-1)*(j-2)/2%MOD; Dp[i][j]%=MOD;
    ^~
tents.cpp:19:56: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    if (j>=3) Dp[i][j]+=Dp[i-1][j-3]*(j-1)*(j-2)/2%MOD; Dp[i][j]%=MOD;
                                                        ^~
tents.cpp:21:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    if (i>=3) Dp[i][j]+=Dp[i-3][j-2]*((i-1)*(j-1)*(i-2)*4%MOD)%MOD; Dp[i][j]%=MOD;
    ^~
tents.cpp:21:68: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    if (i>=3) Dp[i][j]+=Dp[i-3][j-2]*((i-1)*(j-1)*(i-2)*4%MOD)%MOD; Dp[i][j]%=MOD;
                                                                    ^~
tents.cpp:22:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    if (j>=3) Dp[i][j]+=Dp[i-2][j-3]*((j-1)*(i-1)*(j-2)*4%MOD)%MOD; Dp[i][j]%=MOD;
    ^~
tents.cpp:22:68: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    if (j>=3) Dp[i][j]+=Dp[i-2][j-3]*((j-1)*(i-1)*(j-2)*4%MOD)%MOD; Dp[i][j]%=MOD;
                                                                    ^~
tents.cpp:23:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    if (i>=3&&j>=3) Dp[i][j]+=(Dp[i-3][j-3]*((i-1)*(j-1)*(i-2)*(j-2)%MOD))%MOD; Dp[i][j]%=MOD;
    ^~
tents.cpp:23:80: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    if (i>=3&&j>=3) Dp[i][j]+=(Dp[i-3][j-3]*((i-1)*(j-1)*(i-2)*(j-2)%MOD))%MOD; Dp[i][j]%=MOD;
                                                                                ^~
tents.cpp:24:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    if (i>=3) Dp[i][j]+=Dp[i-3][j-2]*((i-1)*(i-2)*(j-1)*2%MOD)%MOD; Dp[i][j]%=MOD;
    ^~
tents.cpp:24:68: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    if (i>=3) Dp[i][j]+=Dp[i-3][j-2]*((i-1)*(i-2)*(j-1)*2%MOD)%MOD; Dp[i][j]%=MOD;
                                                                    ^~
tents.cpp:25:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    if (i>=4) Dp[i][j]+=Dp[i-4][j-2]*(((i-1)*(i-2)/2*(j-1)*(i-3))%MOD)%MOD; Dp[i][j]%=MOD;
    ^~
tents.cpp:25:76: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    if (i>=4) Dp[i][j]+=Dp[i-4][j-2]*(((i-1)*(i-2)/2*(j-1)*(i-3))%MOD)%MOD; Dp[i][j]%=MOD;
                                                                            ^~
tents.cpp:26:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    if (j>=3) Dp[i][j]+=Dp[i-2][j-3]*((j-1)*(j-2)*(i-1)*2%MOD)%MOD; Dp[i][j]%=MOD;
    ^~
tents.cpp:26:68: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    if (j>=3) Dp[i][j]+=Dp[i-2][j-3]*((j-1)*(j-2)*(i-1)*2%MOD)%MOD; Dp[i][j]%=MOD;
                                                                    ^~
tents.cpp:27:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    if (j>=4) Dp[i][j]+=Dp[i-2][j-4]*(((j-1)*(j-2)/2*(i-1)*(j-3))%MOD)%MOD; Dp[i][j]%=MOD;
    ^~
tents.cpp:27:76: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    if (j>=4) Dp[i][j]+=Dp[i-2][j-4]*(((j-1)*(j-2)/2*(i-1)*(j-3))%MOD)%MOD; Dp[i][j]%=MOD;
                                                                            ^~
tents.cpp:28:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    if (i>=3&&j>=3) Dp[i][j]+=(Dp[i-3][j-3]*(((i-1)*(j-1)*(i-2)*(j-2)/4)%MOD))%MOD; Dp[i][j]%=MOD;
    ^~
tents.cpp:28:84: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    if (i>=3&&j>=3) Dp[i][j]+=(Dp[i-3][j-3]*(((i-1)*(j-1)*(i-2)*(j-2)/4)%MOD))%MOD; Dp[i][j]%=MOD;
                                                                                    ^~
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 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 3 ms 688 KB Output is correct
4 Correct 3 ms 1304 KB Output is correct
5 Correct 4 ms 1304 KB Output is correct
6 Correct 6 ms 1692 KB Output is correct
7 Correct 5 ms 1692 KB Output is correct
8 Correct 4 ms 1692 KB Output is correct
9 Correct 2 ms 1692 KB Output is correct
10 Correct 6 ms 1960 KB Output is correct
11 Correct 2 ms 1960 KB Output is correct
12 Correct 10 ms 2512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 3 ms 688 KB Output is correct
4 Correct 3 ms 1304 KB Output is correct
5 Correct 4 ms 1304 KB Output is correct
6 Correct 6 ms 1692 KB Output is correct
7 Correct 5 ms 1692 KB Output is correct
8 Correct 4 ms 1692 KB Output is correct
9 Correct 2 ms 1692 KB Output is correct
10 Correct 6 ms 1960 KB Output is correct
11 Correct 2 ms 1960 KB Output is correct
12 Correct 10 ms 2512 KB Output is correct
13 Correct 2 ms 2512 KB Output is correct
14 Correct 8 ms 9968 KB Output is correct
15 Correct 486 ms 55536 KB Output is correct
16 Correct 33 ms 55536 KB Output is correct
17 Correct 107 ms 55536 KB Output is correct
18 Correct 137 ms 55536 KB Output is correct
19 Correct 567 ms 63292 KB Output is correct
20 Correct 538 ms 63292 KB Output is correct
21 Correct 324 ms 63292 KB Output is correct
22 Correct 343 ms 63292 KB Output is correct
23 Correct 172 ms 63292 KB Output is correct
24 Correct 773 ms 71424 KB Output is correct
25 Correct 568 ms 71424 KB Output is correct
26 Correct 645 ms 71424 KB Output is correct
27 Correct 725 ms 71424 KB Output is correct