Submission #1077663

#TimeUsernameProblemLanguageResultExecution timeMemory
1077663nikolamanolovTents (JOI18_tents)C++14
0 / 100
1 ms2396 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...