Submission #966593

# Submission time Handle Problem Language Result Execution time Memory
966593 2024-04-20T06:06:59 Z Tuanlinh123 Tents (JOI18_tents) C++17
100 / 100
75 ms 70808 KB
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
#define sz(a) ((ll)(a).size())
using namespace std;

const ll maxn=3005, Mod=1e9+7;
ll dp[maxn][maxn];
void upd(ll &a, ll b) {a+=b; if (a>=Mod) a-=Mod;}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll n, m; cin >> n >> m;
    for (ll i=0; i<=n; i++) dp[i][0]=1;
    for (ll i=0; i<=m; i++) dp[0][i]=1;
    for (ll i=1; i<=n; i++)
        for (ll j=1; j<=m; j++)
        {
            upd(dp[i][j], dp[i-1][j]);
            upd(dp[i][j], dp[i-1][j-1]*j*4%Mod);
            if (j>=2) upd(dp[i][j], dp[i-1][j-2]*(j*(j-1)/2)%Mod);
            if (i>=2) upd(dp[i][j], dp[i-2][j-1]*j*(i-1)%Mod);
        }
    cout << (dp[n][m]+Mod-1)%Mod;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 6780 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 2 ms 8536 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 2 ms 8540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 6780 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 2 ms 8536 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 2 ms 8540 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 19 ms 52240 KB Output is correct
15 Correct 48 ms 63572 KB Output is correct
16 Correct 4 ms 6604 KB Output is correct
17 Correct 11 ms 16988 KB Output is correct
18 Correct 14 ms 29296 KB Output is correct
19 Correct 57 ms 67388 KB Output is correct
20 Correct 43 ms 57484 KB Output is correct
21 Correct 28 ms 39604 KB Output is correct
22 Correct 32 ms 52056 KB Output is correct
23 Correct 22 ms 58968 KB Output is correct
24 Correct 75 ms 70808 KB Output is correct
25 Correct 55 ms 61264 KB Output is correct
26 Correct 65 ms 66640 KB Output is correct
27 Correct 73 ms 69128 KB Output is correct