Submission #237254

#TimeUsernameProblemLanguageResultExecution timeMemory
237254Charis02Tents (JOI18_tents)C++14
100 / 100
337 ms71288 KiB
#include<iostream> #include<stdio.h> #include<vector> #include<cmath> #include<queue> #include<string.h> #include<map> #include<set> #include<algorithm> #define ll long long #define pi pair < ll,ll > #define mp(a,b) make_pair(a,b) #define mid (low+high)/2 #define rep(i,a,b) for(int i = a;i < b;i++) #define N 3004 #define INF 1e9+7 using namespace std; ll n,m,mod=1e9+7; ll dp[N][N]; ll solve(ll i,ll j) { if(i < 0 || j < 0) return 0; if(i==0||j==0) return 1; if(dp[i][j]!=-1) return dp[i][j]; return dp[i][j] = ((solve(i-1,j-2)*(j*(j-1))/2)%mod + (solve(i-2,j-1)*(i-1)*j)%mod + (4*j*solve(i-1,j-1))%mod + (solve(i-1,j)))%mod; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); memset(dp,-1,sizeof dp); cin >> n >> m; cout << (solve(n,m)-1+mod)%mod << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...