# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
43966 | 2018-03-29T01:15:50 Z | model_code | Tents (JOI18_tents) | C++17 | 119 ms | 71204 KB |
#include<cstdio> #include<algorithm> using namespace std; const long long mod = 1000000007; const int MAX_N = 3000; long long dp[MAX_N + 1][MAX_N + 1]; int H, W; long long C2(int x){ return x * (x - 1) / 2; } long long solve(){ for(int i = 0; i <= H; ++i){ for(int j = 0; j <= W; ++j){ if(i == 0 || j == 0){ dp[i][j] = 1; }else{ dp[i][j] = 0; dp[i][j] += dp[i][j - 1]; dp[i][j] += 4ll * i * dp[i - 1][j - 1]; if(i >= 2){ long long tmp = C2(i); dp[i][j] += tmp * dp[i - 2][j - 1]; } if(j >= 2){ dp[i][j] += (long long)i * (j - 1) * dp[i - 1][j - 2]; } dp[i][j] %= mod; } } } long long ans = dp[H][W] - 1; ans %= mod; ans += mod; ans %= mod; return ans; } int main(){ scanf("%d%d", &H, &W); long long ans = solve(); printf("%lld\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 488 KB | Output is correct |
3 | Correct | 2 ms | 564 KB | Output is correct |
4 | Correct | 2 ms | 1288 KB | Output is correct |
5 | Correct | 2 ms | 1288 KB | Output is correct |
6 | Correct | 3 ms | 1668 KB | Output is correct |
7 | Correct | 2 ms | 1668 KB | Output is correct |
8 | Correct | 2 ms | 1668 KB | Output is correct |
9 | Correct | 2 ms | 1668 KB | Output is correct |
10 | Correct | 3 ms | 1936 KB | Output is correct |
11 | Correct | 2 ms | 1936 KB | Output is correct |
12 | Correct | 3 ms | 2400 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 488 KB | Output is correct |
3 | Correct | 2 ms | 564 KB | Output is correct |
4 | Correct | 2 ms | 1288 KB | Output is correct |
5 | Correct | 2 ms | 1288 KB | Output is correct |
6 | Correct | 3 ms | 1668 KB | Output is correct |
7 | Correct | 2 ms | 1668 KB | Output is correct |
8 | Correct | 2 ms | 1668 KB | Output is correct |
9 | Correct | 2 ms | 1668 KB | Output is correct |
10 | Correct | 3 ms | 1936 KB | Output is correct |
11 | Correct | 2 ms | 1936 KB | Output is correct |
12 | Correct | 3 ms | 2400 KB | Output is correct |
13 | Correct | 2 ms | 2400 KB | Output is correct |
14 | Correct | 7 ms | 9896 KB | Output is correct |
15 | Correct | 80 ms | 55532 KB | Output is correct |
16 | Correct | 7 ms | 55532 KB | Output is correct |
17 | Correct | 20 ms | 55532 KB | Output is correct |
18 | Correct | 25 ms | 55532 KB | Output is correct |
19 | Correct | 92 ms | 63328 KB | Output is correct |
20 | Correct | 81 ms | 63328 KB | Output is correct |
21 | Correct | 50 ms | 63328 KB | Output is correct |
22 | Correct | 49 ms | 63328 KB | Output is correct |
23 | Correct | 35 ms | 63328 KB | Output is correct |
24 | Correct | 119 ms | 71204 KB | Output is correct |
25 | Correct | 92 ms | 71204 KB | Output is correct |
26 | Correct | 105 ms | 71204 KB | Output is correct |
27 | Correct | 112 ms | 71204 KB | Output is correct |