답안 #878331

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
878331 2023-11-24T08:19:27 Z Erfan1386Y Tents (JOI18_tents) C++17
100 / 100
91 ms 70996 KB
#include <bits/stdc++.h>
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define fast_io ios::sync_with_stdio(false);cin.tie(0);
#define what(x) cerr << #x << " is " << x << endl;
#define kill(x) {cout << x << '\n'; return 0;}
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define ll long long
#define F first
#define S second
const ll inf = 8e18, mod = 1e9 + 7, delta = 1e8, SQ = 700; //998244353

using namespace std;

const ll N = 3e3 + 10, LG = 20;
ll dp[N][N];

int32_t main() {
  fast_io; 
  int n, m;
  cin >> n >> m;
  dp[0][0] = 1;
  dp[1][1] = 5;
  for (int i = 1; i <= n; i++) dp[i][0] = 1;
  for (int i = 1; i <= m; i++) dp[0][i] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (i == 1 && j == 1) continue;
      dp[i][j] = dp[i - 1][j];
      dp[i][j] += (4 * j * dp[i - 1][j - 1] % mod);
      dp[i][j] %= mod;
      if (i >= 2) dp[i][j] += (j * (i - 1) * dp[i - 2][j - 1] % mod);
      dp[i][j] %= mod;
      if (j >= 2) dp[i][j] += (j * (j - 1) / 2 * dp[i - 1][j - 2] % mod);
      dp[i][j] %= mod;
    }
  }
  cout << dp[n][m] - 1 << '\n';
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 2 ms 8540 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 2 ms 8540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 2 ms 8540 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 2 ms 8540 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 7 ms 55900 KB Output is correct
15 Correct 59 ms 64628 KB Output is correct
16 Correct 4 ms 6744 KB Output is correct
17 Correct 13 ms 16988 KB Output is correct
18 Correct 19 ms 29276 KB Output is correct
19 Correct 69 ms 68176 KB Output is correct
20 Correct 53 ms 59996 KB Output is correct
21 Correct 35 ms 39516 KB Output is correct
22 Correct 36 ms 51868 KB Output is correct
23 Correct 25 ms 70432 KB Output is correct
24 Correct 91 ms 70996 KB Output is correct
25 Correct 67 ms 62040 KB Output is correct
26 Correct 77 ms 66644 KB Output is correct
27 Correct 88 ms 69272 KB Output is correct