# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1055042 | 2024-08-12T14:12:11 Z | manhlinh1501 | Tents (JOI18_tents) | C++17 | 107 ms | 144332 KB |
#include <bits/stdc++.h> using namespace std; using i64 = long long; const int MAXN = 3e3 + 5; const i64 MOD = 1e9 + 7; int N, M; i64 dp[MAXN][MAXN]; i64 MUL(i64 a, i64 b) { return (a * b) % MOD; } i64 ADD(i64 a, i64 b) { return (a + b) % MOD; } i64 calc(int r, int c) { if(c < 0 or c < 0) return 0; if(r == 0 or c == 0) return 1; i64 &res = dp[r][c]; if(res != -1) return res; res = 0; res = ADD(res, MUL(c * (c - 1) / 2, calc(r - 1, c - 2))); res = ADD(res, calc(r - 1, c)); res = ADD(res, MUL(4 * c, calc(r - 1, c - 1))); res = ADD(res, MUL(c * (r - 1), calc(r - 2, c - 1))); return res; } signed main() { #define TASK "code" if (fopen(TASK ".inp", "r")) { freopen(TASK ".inp", "r", stdin); freopen(TASK ".out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N >> M; memset(dp, -1, sizeof dp); cout << (calc(N, M) - 1 + MOD) % MOD; return (0 ^ 0); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 71000 KB | Output is correct |
2 | Correct | 7 ms | 71004 KB | Output is correct |
3 | Correct | 7 ms | 71056 KB | Output is correct |
4 | Correct | 7 ms | 71000 KB | Output is correct |
5 | Correct | 8 ms | 71128 KB | Output is correct |
6 | Correct | 8 ms | 71156 KB | Output is correct |
7 | Correct | 7 ms | 71116 KB | Output is correct |
8 | Correct | 8 ms | 71004 KB | Output is correct |
9 | Correct | 7 ms | 71060 KB | Output is correct |
10 | Correct | 9 ms | 71160 KB | Output is correct |
11 | Correct | 8 ms | 71000 KB | Output is correct |
12 | Correct | 9 ms | 71256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 71000 KB | Output is correct |
2 | Correct | 7 ms | 71004 KB | Output is correct |
3 | Correct | 7 ms | 71056 KB | Output is correct |
4 | Correct | 7 ms | 71000 KB | Output is correct |
5 | Correct | 8 ms | 71128 KB | Output is correct |
6 | Correct | 8 ms | 71156 KB | Output is correct |
7 | Correct | 7 ms | 71116 KB | Output is correct |
8 | Correct | 8 ms | 71004 KB | Output is correct |
9 | Correct | 7 ms | 71060 KB | Output is correct |
10 | Correct | 9 ms | 71160 KB | Output is correct |
11 | Correct | 8 ms | 71000 KB | Output is correct |
12 | Correct | 9 ms | 71256 KB | Output is correct |
13 | Correct | 7 ms | 71004 KB | Output is correct |
14 | Correct | 7 ms | 71312 KB | Output is correct |
15 | Runtime error | 107 ms | 144332 KB | Execution killed with signal 11 |
16 | Halted | 0 ms | 0 KB | - |