답안 #44045

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
44045 2018-03-29T12:47:49 Z wxh010910 Tents (JOI18_tents) C++17
100 / 100
89 ms 35872 KB
#include <bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

template <typename T> inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}

template <typename T> inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}

const int N = 3005;
const int mod = 1e9 + 7;

int n, m, ans, f[N][N];

int main() {
#ifdef wxh010910
  freopen("d.in", "r", stdin);
#endif
  Read(n), Read(m), f[0][m] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= m; ++j) {
      f[i][j] = (1LL * (j + 2) * (j + 1) / 2 * f[i - 1][j + 2] + 4LL * (j + 1) * f[i - 1][j + 1] + f[i - 1][j]) % mod;
      if (i >= 2) {
        f[i][j] = (1LL * (i - 1) * (j + 1) * f[i - 2][j + 1] + f[i][j]) % mod;
      }
    }
  }
  for (int i = 0; i <= m; ++i) {
    ans = (ans + f[n][i]) % mod;
  }
  printf("%d\n", (ans + mod - 1) % mod);
#ifdef wxh010910
  Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 696 KB Output is correct
4 Correct 2 ms 1276 KB Output is correct
5 Correct 2 ms 1276 KB Output is correct
6 Correct 2 ms 1564 KB Output is correct
7 Correct 3 ms 1564 KB Output is correct
8 Correct 2 ms 1608 KB Output is correct
9 Correct 2 ms 1608 KB Output is correct
10 Correct 3 ms 1864 KB Output is correct
11 Correct 2 ms 1864 KB Output is correct
12 Correct 4 ms 2080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 696 KB Output is correct
4 Correct 2 ms 1276 KB Output is correct
5 Correct 2 ms 1276 KB Output is correct
6 Correct 2 ms 1564 KB Output is correct
7 Correct 3 ms 1564 KB Output is correct
8 Correct 2 ms 1608 KB Output is correct
9 Correct 2 ms 1608 KB Output is correct
10 Correct 3 ms 1864 KB Output is correct
11 Correct 2 ms 1864 KB Output is correct
12 Correct 4 ms 2080 KB Output is correct
13 Correct 2 ms 2080 KB Output is correct
14 Correct 7 ms 9804 KB Output is correct
15 Correct 61 ms 33020 KB Output is correct
16 Correct 6 ms 33020 KB Output is correct
17 Correct 15 ms 33020 KB Output is correct
18 Correct 19 ms 33020 KB Output is correct
19 Correct 70 ms 34780 KB Output is correct
20 Correct 60 ms 34780 KB Output is correct
21 Correct 39 ms 34780 KB Output is correct
22 Correct 39 ms 34780 KB Output is correct
23 Correct 27 ms 34780 KB Output is correct
24 Correct 89 ms 35872 KB Output is correct
25 Correct 69 ms 35872 KB Output is correct
26 Correct 75 ms 35872 KB Output is correct
27 Correct 85 ms 35872 KB Output is correct