# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
338017 | 2020-12-22T09:06:22 Z | BeanZ | Tents (JOI18_tents) | C++14 | 413 ms | 71404 KB |
// I_Love_LPL #include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' const int N = 3005; long long mod = 1e9 + 7; const int lim = 700; const int lg = 18; const int base = 311; const long double eps = 1e-6; ll dp[N][N]; ll DP(ll h, ll w){ if (h == 0 || w == 0) return 1; if (dp[h][w] != -1) return dp[h][w]; ll res = 0; res = res + w * 4 * DP(h - 1, w - 1); res = res + DP(h - 1, w); if (h > 1) res = res + (h - 1) * w * DP(h - 2, w - 1); if (w > 1) res = res + w * (w - 1) / 2 * DP(h - 1, w - 2); res = res % mod; return dp[h][w] = res; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); if (fopen("tests.inp", "r")){ freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } ll h, w; cin >> h >> w; memset(dp, -1, sizeof(dp)); cout << (DP(h, w) - 1 + mod) % mod; } /* Out: */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 71020 KB | Output is correct |
2 | Correct | 39 ms | 71148 KB | Output is correct |
3 | Correct | 40 ms | 71020 KB | Output is correct |
4 | Correct | 38 ms | 71020 KB | Output is correct |
5 | Correct | 39 ms | 71148 KB | Output is correct |
6 | Correct | 38 ms | 71020 KB | Output is correct |
7 | Correct | 37 ms | 71020 KB | Output is correct |
8 | Correct | 39 ms | 71148 KB | Output is correct |
9 | Correct | 37 ms | 71020 KB | Output is correct |
10 | Correct | 38 ms | 71020 KB | Output is correct |
11 | Correct | 38 ms | 71020 KB | Output is correct |
12 | Correct | 38 ms | 71020 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 71020 KB | Output is correct |
2 | Correct | 39 ms | 71148 KB | Output is correct |
3 | Correct | 40 ms | 71020 KB | Output is correct |
4 | Correct | 38 ms | 71020 KB | Output is correct |
5 | Correct | 39 ms | 71148 KB | Output is correct |
6 | Correct | 38 ms | 71020 KB | Output is correct |
7 | Correct | 37 ms | 71020 KB | Output is correct |
8 | Correct | 39 ms | 71148 KB | Output is correct |
9 | Correct | 37 ms | 71020 KB | Output is correct |
10 | Correct | 38 ms | 71020 KB | Output is correct |
11 | Correct | 38 ms | 71020 KB | Output is correct |
12 | Correct | 38 ms | 71020 KB | Output is correct |
13 | Correct | 35 ms | 71020 KB | Output is correct |
14 | Correct | 37 ms | 71148 KB | Output is correct |
15 | Correct | 290 ms | 71292 KB | Output is correct |
16 | Correct | 42 ms | 71148 KB | Output is correct |
17 | Correct | 55 ms | 71148 KB | Output is correct |
18 | Correct | 79 ms | 71148 KB | Output is correct |
19 | Correct | 315 ms | 71276 KB | Output is correct |
20 | Correct | 254 ms | 71264 KB | Output is correct |
21 | Correct | 163 ms | 71148 KB | Output is correct |
22 | Correct | 174 ms | 71148 KB | Output is correct |
23 | Correct | 135 ms | 71232 KB | Output is correct |
24 | Correct | 413 ms | 71308 KB | Output is correct |
25 | Correct | 302 ms | 71276 KB | Output is correct |
26 | Correct | 352 ms | 71296 KB | Output is correct |
27 | Correct | 407 ms | 71404 KB | Output is correct |