답안 #860432

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
860432 2023-10-13T01:44:45 Z rxlfd314 Tents (JOI18_tents) C++17
100 / 100
130 ms 35796 KB
#include <bits/stdc++.h>
using namespace std;

#define vt vector
#define size(x) (int((x).size()))
#define all(x) begin(x), end(x)

#define REP(a, b, c, d) for (int a = (b); (d) > 0 ? a <= (c) : a >= (c); a += (d))
#define FOR(a, b, c) REP(a, b, c, 1)
#define ROF(a, b, c) REP(a, b, c, -1)

#define chmax(a, b) a = a > (b) ? a : (b)
#define chmin(a, b) a = a < (b) ? a : (b)

signed main() {
#ifndef DEBUG
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  constexpr int MOD = 1e9 + 7;
  int N, M;
  cin >> N >> M;
  vt<vt<int>> f(N+1, vt<int>(M+1));
  fill(all(f[0]), 1);
  FOR(i, 0, N)
    f[i][0] = 1;
  FOR(i, 1, N)
    FOR(j, 1, M) {
      f[i][j] = f[i][j-1];
      (f[i][j] += 4ll * f[i-1][j-1] * i % MOD) %= MOD;
      if (j > 1)
        (f[i][j] += 1ll * f[i-1][j-2] * i % MOD * (j - 1) % MOD) %= MOD;
      if (i > 1)
        (f[i][j] += 1ll * f[i-2][j-1] * i * (i - 1) / 2 % MOD) %= MOD;
    }
  cout << (f[N][M] + MOD - 1) % MOD << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 600 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 2 ms 712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 600 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 2 ms 712 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 80 ms 22364 KB Output is correct
16 Correct 6 ms 1628 KB Output is correct
17 Correct 18 ms 5212 KB Output is correct
18 Correct 22 ms 6492 KB Output is correct
19 Correct 93 ms 25944 KB Output is correct
20 Correct 75 ms 20828 KB Output is correct
21 Correct 50 ms 13912 KB Output is correct
22 Correct 49 ms 13764 KB Output is correct
23 Correct 27 ms 7772 KB Output is correct
24 Correct 128 ms 35796 KB Output is correct
25 Correct 98 ms 26664 KB Output is correct
26 Correct 109 ms 30556 KB Output is correct
27 Correct 130 ms 34440 KB Output is correct