Submission #1077663

# Submission time Handle Problem Language Result Execution time Memory
1077663 2024-08-27T08:31:55 Z nikolamanolov Tents (JOI18_tents) C++14
0 / 100
1 ms 2396 KB
#include<bits/stdc++.h>
using namespace std;
const long long MOD=1e9+7;
long long dp[3004][3004];
bool iz[3004][3004];
long long rec(long long i, long long j)
{
    if (i<0 || j<0) return 0;
    if (i==0 || j==0) return 1;

    if (iz[i][j]) return dp[i][j];

    long long ans=0;
    ans=(ans+rec(i-1, j))%MOD;
    ans=(ans+rec(i-1, j-1)*4*j)%MOD;
    ans=(ans+rec(i-1, j-2)*(j*(j-1)/2))%MOD;
    ans=(ans+rec(i-2, j-1)*j*(i-1))%MOD;
    iz[i][j]=true;
    return dp[i][j]=ans;
}

long long n, m;

int main ()
{
    cin>>n>>m;
    cout<<rec(n, m)<<endl;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -