Submission #56307

# Submission time Handle Problem Language Result Execution time Memory
56307 2018-07-11T03:56:30 Z khsoo01(#2109) Tents (JOI18_tents) C++11
100 / 100
127 ms 71348 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll N = 3005, mod = 1e9+7;

ll h, w, dt[N][N];

int main()
{
	scanf("%lld%lld",&h,&w);
	for(ll i=0;i<=w;i++) dt[0][i] = 1;
	for(ll i=1;i<=h;i++) {
		dt[i][0] = 1;
		for(ll j=1;j<=w;j++) {
			dt[i][j] = (dt[i-1][j] + dt[i-1][j-1] * 4 * j) % mod;
			if(i >= 2) dt[i][j] = (dt[i][j] + dt[i-2][j-1] * j * (i-1)) % mod;
			if(j >= 2) dt[i][j] = (dt[i][j] + dt[i-1][j-2] * j * (j-1) / 2) % mod;
		}
	}
	printf("%lld\n",(dt[h][w]+mod-1)%mod);
}

Compilation message

tents.cpp: In function 'int main()':
tents.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld",&h,&w);
  ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 496 KB Output is correct
3 Correct 2 ms 548 KB Output is correct
4 Correct 3 ms 1368 KB Output is correct
5 Correct 6 ms 1368 KB Output is correct
6 Correct 5 ms 1736 KB Output is correct
7 Correct 3 ms 1736 KB Output is correct
8 Correct 4 ms 1852 KB Output is correct
9 Correct 3 ms 1852 KB Output is correct
10 Correct 5 ms 2160 KB Output is correct
11 Correct 3 ms 2160 KB Output is correct
12 Correct 5 ms 2680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 496 KB Output is correct
3 Correct 2 ms 548 KB Output is correct
4 Correct 3 ms 1368 KB Output is correct
5 Correct 6 ms 1368 KB Output is correct
6 Correct 5 ms 1736 KB Output is correct
7 Correct 3 ms 1736 KB Output is correct
8 Correct 4 ms 1852 KB Output is correct
9 Correct 3 ms 1852 KB Output is correct
10 Correct 5 ms 2160 KB Output is correct
11 Correct 3 ms 2160 KB Output is correct
12 Correct 5 ms 2680 KB Output is correct
13 Correct 2 ms 2680 KB Output is correct
14 Correct 11 ms 10112 KB Output is correct
15 Correct 102 ms 55680 KB Output is correct
16 Correct 12 ms 55680 KB Output is correct
17 Correct 22 ms 55680 KB Output is correct
18 Correct 31 ms 55680 KB Output is correct
19 Correct 105 ms 63440 KB Output is correct
20 Correct 95 ms 63440 KB Output is correct
21 Correct 63 ms 63440 KB Output is correct
22 Correct 63 ms 63440 KB Output is correct
23 Correct 35 ms 63440 KB Output is correct
24 Correct 127 ms 71348 KB Output is correct
25 Correct 103 ms 71348 KB Output is correct
26 Correct 108 ms 71348 KB Output is correct
27 Correct 123 ms 71348 KB Output is correct