Submission #159106

# Submission time Handle Problem Language Result Execution time Memory
159106 2019-10-20T21:22:31 Z ppnxblstr Tents (JOI18_tents) C++14
100 / 100
121 ms 35668 KB
#include <bits/stdc++.h>
using namespace std;
int dp[3005][3005];
const int MOD = 1e9+7;
int main(){
    int h,w;
    scanf("%d%d",&h,&w);
    for(int i = 1; i < 3005; i++){
        dp[1][i] = 1ll * i * (i-1) / 2ll + 4ll * i + 1ll;
        dp[1][i] %= 1ll * MOD;
        dp[i][1] = dp[1][i];
        dp[0][i] = dp[i][0] = 1ll;
    }
    dp[0][0] = 1ll;
    for(int r = 2; r <= h; r++){
        for(int c = 2; c <= w; c++){
            long long l = 1ll * r * (r-1ll) / 2ll;
            l %= 1ll * MOD;
            l *= 1ll * dp[r-2][c-1];
            l %= 1ll * MOD;
            l += 1ll * (c-1) * r * dp[r-1][c-2];
            l %= 1ll * MOD;
            l += 4ll * r * dp[r-1][c-1];
            l %= 1ll * MOD;
            l += 1ll * dp[r][c-1];
            l %= 1ll * MOD;
            dp[r][c] = l;
        }
    }
    printf("%d\n",(dp[h][w]+MOD-1) % MOD);
    return 0;
}

Compilation message

tents.cpp: In function 'int main()':
tents.cpp:7:10: 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 13 ms 12416 KB Output is correct
2 Correct 11 ms 12536 KB Output is correct
3 Correct 11 ms 12408 KB Output is correct
4 Correct 11 ms 12508 KB Output is correct
5 Correct 23 ms 12520 KB Output is correct
6 Correct 11 ms 12536 KB Output is correct
7 Correct 11 ms 12536 KB Output is correct
8 Correct 11 ms 12536 KB Output is correct
9 Correct 11 ms 12452 KB Output is correct
10 Correct 11 ms 12536 KB Output is correct
11 Correct 11 ms 12408 KB Output is correct
12 Correct 12 ms 12792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 12416 KB Output is correct
2 Correct 11 ms 12536 KB Output is correct
3 Correct 11 ms 12408 KB Output is correct
4 Correct 11 ms 12508 KB Output is correct
5 Correct 23 ms 12520 KB Output is correct
6 Correct 11 ms 12536 KB Output is correct
7 Correct 11 ms 12536 KB Output is correct
8 Correct 11 ms 12536 KB Output is correct
9 Correct 11 ms 12452 KB Output is correct
10 Correct 11 ms 12536 KB Output is correct
11 Correct 11 ms 12408 KB Output is correct
12 Correct 12 ms 12792 KB Output is correct
13 Correct 10 ms 12408 KB Output is correct
14 Correct 11 ms 12408 KB Output is correct
15 Correct 85 ms 33784 KB Output is correct
16 Correct 16 ms 13792 KB Output is correct
17 Correct 28 ms 17272 KB Output is correct
18 Correct 32 ms 18424 KB Output is correct
19 Correct 95 ms 34936 KB Output is correct
20 Correct 79 ms 31392 KB Output is correct
21 Correct 56 ms 25208 KB Output is correct
22 Correct 56 ms 25704 KB Output is correct
23 Correct 36 ms 19704 KB Output is correct
24 Correct 121 ms 35668 KB Output is correct
25 Correct 94 ms 32504 KB Output is correct
26 Correct 107 ms 34288 KB Output is correct
27 Correct 118 ms 35028 KB Output is correct