Submission #230946

#TimeUsernameProblemLanguageResultExecution timeMemory
230946AlexLuchianovTents (JOI18_tents)C++14
100 / 100
225 ms31992 KiB
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>

using namespace std;

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 3000;
int const modulo = 1000000007;
int dp[1 + nmax][1 + nmax];

int extract(int i, int j){
  if(i < 0 || j < 0)
    return 0;
  else if(i == 0 || j == 0)
    return 1;
  else if(dp[i][j] == 0){
    dp[i][j] = (extract(i - 1, j) +
               1LL * extract(i - 1, j - 1) * (j * 4) +
               1LL * extract(i - 1, j - 2) * ((j * (j - 1)) / 2) +
               1LL * extract(i - 2, j - 1) * j * (i - 1)) % modulo;
   }
  return dp[i][j];
}
int main()
{
  int n, m;
  cin >> n >> m;
  cout << (modulo + extract(n, m) - 1) % modulo;
  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...