Submission #898471

# Submission time Handle Problem Language Result Execution time Memory
898471 2024-01-04T17:55:42 Z maxFedorchuk Tents (JOI18_tents) C++17
48 / 100
2 ms 1120 KB
#include <bits/stdc++.h>
using namespace std;

const long long MOD=1e9+7;

const long long MX=330;

long long dp[MX][MX];

long long cntdp(long long n,long long m)
{
    if(n<=0 || m<=0)
    {
        return 1;
    }

    if(dp[n][m])
    {
        return dp[n][m];
    }

    dp[n][m]=cntdp(n-1,m);

    dp[n][m]=(cntdp(n-1,m-1)*4*m+dp[n][m])%MOD;

    dp[n][m]=((cntdp(n-1,m-2)*(m*(m-1)/2))%MOD+dp[n][m])%MOD;

    dp[n][m]=((cntdp(n-2,m-1)*m*(n-1))%MOD+dp[n][m])%MOD;

    return dp[n][m];
}
int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);

    long long n,m;
    cin>>n>>m;

    cout<<(cntdp(n,m)-1+MOD)%MOD<<"\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 352 KB Output is correct
2 Correct 0 ms 352 KB Output is correct
3 Correct 0 ms 352 KB Output is correct
4 Correct 1 ms 872 KB Output is correct
5 Correct 0 ms 608 KB Output is correct
6 Correct 1 ms 864 KB Output is correct
7 Correct 1 ms 608 KB Output is correct
8 Correct 1 ms 988 KB Output is correct
9 Correct 1 ms 608 KB Output is correct
10 Correct 1 ms 1120 KB Output is correct
11 Correct 0 ms 352 KB Output is correct
12 Correct 2 ms 1120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 352 KB Output is correct
2 Correct 0 ms 352 KB Output is correct
3 Correct 0 ms 352 KB Output is correct
4 Correct 1 ms 872 KB Output is correct
5 Correct 0 ms 608 KB Output is correct
6 Correct 1 ms 864 KB Output is correct
7 Correct 1 ms 608 KB Output is correct
8 Correct 1 ms 988 KB Output is correct
9 Correct 1 ms 608 KB Output is correct
10 Correct 1 ms 1120 KB Output is correct
11 Correct 0 ms 352 KB Output is correct
12 Correct 2 ms 1120 KB Output is correct
13 Correct 0 ms 352 KB Output is correct
14 Runtime error 1 ms 600 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -