Submission #1014356

#TimeUsernameProblemLanguageResultExecution timeMemory
1014356MarwenElarbiTents (JOI18_tents)C++17
100 / 100
166 ms58960 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #define fi first #define se second #define ll long long #define pb push_back #define ii pair<int,int> template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; const int nax=3e3+5; const int MOD=1e9+7; #define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); long long dp[nax][nax]; long long dfs(ll x,ll y){ if(x<0||y<0) return 0; if(x==0) return 1; if(dp[x][y]) return dp[x][y]; dp[x][y]+=dfs(x-1,y-2)*(y*(y-1)/2)%MOD; dp[x][y]%=MOD; dp[x][y]+=dfs(x-1,y)%MOD; dp[x][y]%=MOD; dp[x][y]+=dfs(x-1,y-1)*(y*4)%MOD; dp[x][y]%=MOD; dp[x][y]+=dfs(x-2,y-1)*(y*(x-1))%MOD; dp[x][y]%=MOD; return dp[x][y]; } int main() { optimise; int n,m; cin>>n>>m; dp[0][0]=1; cout << dfs(n,m)-1<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...