Submission #236802

#TimeUsernameProblemLanguageResultExecution timeMemory
236802uacoder123Tents (JOI18_tents)C++14
100 / 100
256 ms63352 KiB
 #include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define mp(i,a) make_pair(i,a)
#define pb(a) push_back(a)
#define bit(x,b) (x&(1LL<<b))

typedef long long int lli;
typedef pair <lli,lli> ii;
typedef pair <ii,lli> iii;
typedef vector <lli> vi;
lli dp[3001][3001]={};
lli m=1000000007;
lli cal(lli h,lli w)
{
  if(h<=0||w<=0)
    return(1);
  if(dp[h][w])
    return(dp[h][w]);
  dp[h][w]=((((h*(h-1))/2)*cal(h-2,w-1))%m+(4*h*cal(h-1,w-1))%m+(h*(w-1)*cal(h-1,w-2))%m+cal(h,w-1))%m;
  return(dp[h][w]);
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  lli test;
  test=1;
  for(;test>0;--test)
  {
    dp[1][1]=5;
    lli h,w;
    cin>>h>>w;
    cout<<(cal(h,w)-1+m)%m<<endl;
  }
  return(0);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...