Submission #84378

# Submission time Handle Problem Language Result Execution time Memory
84378 2018-11-14T20:11:39 Z Alexa2001 Tents (JOI18_tents) C++17
100 / 100
228 ms 36056 KB
#include <bits/stdc++.h>

using namespace std;

const int Mod = 1e9 + 7, Nmax = 3003;
typedef long long ll;

int inm(int x, int y) { return (ll)x*y%Mod; }
void add_to(int &x, int y) { x+=y; if(x>=Mod) x-=Mod; }

int n, m, i, j, dp[Nmax][Nmax];

int main()
{
  //  freopen("input", "r", stdin);
    cin.sync_with_stdio(false);

    cin >> n >> m;
    for(i=0; i<=n || i<=m; ++i) dp[0][i] = dp[i][0] = 1;

    for(i=1; i<=n; ++i)
        for(j=1; j<=m; ++j)
        {
            dp[i][j] = dp[i-1][j];

            if(j>=2) add_to(dp[i][j], inm(dp[i-1][j-2], j*(j-1)/2));
            if(i>=2) add_to(dp[i][j], inm(dp[i-2][j-1], (i-1) * j));

            add_to(dp[i][j], inm(4 * j, dp[i-1][j-1]));
        }

    add_to(dp[n][m], Mod-1);
    cout << dp[n][m] << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 1152 KB Output is correct
3 Correct 2 ms 1152 KB Output is correct
4 Correct 3 ms 1472 KB Output is correct
5 Correct 3 ms 1536 KB Output is correct
6 Correct 4 ms 1584 KB Output is correct
7 Correct 4 ms 1628 KB Output is correct
8 Correct 3 ms 1644 KB Output is correct
9 Correct 2 ms 1644 KB Output is correct
10 Correct 4 ms 1940 KB Output is correct
11 Correct 3 ms 1940 KB Output is correct
12 Correct 5 ms 2256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 1152 KB Output is correct
3 Correct 2 ms 1152 KB Output is correct
4 Correct 3 ms 1472 KB Output is correct
5 Correct 3 ms 1536 KB Output is correct
6 Correct 4 ms 1584 KB Output is correct
7 Correct 4 ms 1628 KB Output is correct
8 Correct 3 ms 1644 KB Output is correct
9 Correct 2 ms 1644 KB Output is correct
10 Correct 4 ms 1940 KB Output is correct
11 Correct 3 ms 1940 KB Output is correct
12 Correct 5 ms 2256 KB Output is correct
13 Correct 8 ms 8092 KB Output is correct
14 Correct 9 ms 9888 KB Output is correct
15 Correct 143 ms 33104 KB Output is correct
16 Correct 15 ms 33104 KB Output is correct
17 Correct 43 ms 33104 KB Output is correct
18 Correct 56 ms 33104 KB Output is correct
19 Correct 164 ms 34912 KB Output is correct
20 Correct 135 ms 34912 KB Output is correct
21 Correct 89 ms 34912 KB Output is correct
22 Correct 89 ms 34912 KB Output is correct
23 Correct 56 ms 34912 KB Output is correct
24 Correct 222 ms 36056 KB Output is correct
25 Correct 169 ms 36056 KB Output is correct
26 Correct 193 ms 36056 KB Output is correct
27 Correct 228 ms 36056 KB Output is correct