# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
641092 | 2022-09-16T01:34:18 Z | ghostwriter | Tents (JOI18_tents) | C++14 | 123 ms | 63236 KB |
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include <debug.h> #endif #define st first #define nd second #define pb push_back #define pf push_front #define _pb pop_back #define _pf pop_front #define lb lower_bound #define ub upper_bound #define mtp make_tuple #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ldb; typedef pair<int, int> pi; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll; typedef string str; template<typename T> T gcd(T a, T b) { return (b == 0? a : gcd(b, a % b)); } template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i)) #define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i)) #define EACH(i, x) for (auto &(i) : (x)) #define WHILE while #define file "TEST" mt19937 rd(chrono::steady_clock::now().time_since_epoch().count()); ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); } /* Tran The Bao CTL - Da Lat Cay ngay cay dem nhung deo duoc cong nhan */ const int M = 1e9 + 7; const int N = 3005; int h, w, c[N][N], d[N][N], f[N], pi2[N], rs = 0; signed main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); // freopen(file".inp", "r", stdin); // freopen(file".out", "w", stdout); cin >> h >> w; FOR(i, 0, h) FOR(j, 0, w) if (i == 0 || j == 0) d[i][j] = 1; else d[i][j] = (d[i][j - 1] + 4LL * i * d[i - 1][j - 1] % M) % M; FOR(i, 0, max(h, w)) FOR(j, 0, i) if (j == 0) c[i][j] = 1; else c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % M; f[0] = pi2[0] = 1; int inv2 = (-M / 2 + M) % M; FOR(i, 1, max(h, w)) { f[i] = 1LL * f[i - 1] * i % M; pi2[i] = 1LL * pi2[i - 1] * inv2 % M; } FOR(i, 0, min(h, w / 2)) { int tmp1 = 1LL * c[h][i] * c[w][2 * i] % M * f[2 * i] % M *pi2[i] % M; int rmx = h - i, rmy = w - 2 * i; FOR(j, 0, min(rmy, rmx / 2)) { int tmp2 = 1LL * c[rmy][j] * c[rmx][2 * j] % M * f[2 * j] % M * pi2[j] % M; int tmp3 = d[rmx - 2 * j][rmy - j]; rs = (rs + 1LL * tmp1 * tmp2 % M * tmp3 % M) % M; } } cout << (rs - 1) % M; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 1108 KB | Output is correct |
3 | Correct | 1 ms | 724 KB | Output is correct |
4 | Correct | 1 ms | 2004 KB | Output is correct |
5 | Correct | 1 ms | 1748 KB | Output is correct |
6 | Correct | 1 ms | 2260 KB | Output is correct |
7 | Correct | 1 ms | 1708 KB | Output is correct |
8 | Correct | 1 ms | 2508 KB | Output is correct |
9 | Correct | 1 ms | 1352 KB | Output is correct |
10 | Correct | 2 ms | 2900 KB | Output is correct |
11 | Correct | 1 ms | 1748 KB | Output is correct |
12 | Correct | 2 ms | 3284 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 1108 KB | Output is correct |
3 | Correct | 1 ms | 724 KB | Output is correct |
4 | Correct | 1 ms | 2004 KB | Output is correct |
5 | Correct | 1 ms | 1748 KB | Output is correct |
6 | Correct | 1 ms | 2260 KB | Output is correct |
7 | Correct | 1 ms | 1708 KB | Output is correct |
8 | Correct | 1 ms | 2508 KB | Output is correct |
9 | Correct | 1 ms | 1352 KB | Output is correct |
10 | Correct | 2 ms | 2900 KB | Output is correct |
11 | Correct | 1 ms | 1748 KB | Output is correct |
12 | Correct | 2 ms | 3284 KB | Output is correct |
13 | Correct | 8 ms | 14292 KB | Output is correct |
14 | Correct | 15 ms | 29000 KB | Output is correct |
15 | Correct | 78 ms | 57732 KB | Output is correct |
16 | Correct | 10 ms | 13652 KB | Output is correct |
17 | Correct | 21 ms | 21632 KB | Output is correct |
18 | Correct | 20 ms | 19928 KB | Output is correct |
19 | Correct | 88 ms | 61140 KB | Output is correct |
20 | Correct | 72 ms | 50260 KB | Output is correct |
21 | Correct | 44 ms | 36476 KB | Output is correct |
22 | Correct | 48 ms | 40020 KB | Output is correct |
23 | Correct | 34 ms | 47304 KB | Output is correct |
24 | Correct | 123 ms | 63236 KB | Output is correct |
25 | Correct | 87 ms | 53580 KB | Output is correct |
26 | Correct | 99 ms | 58960 KB | Output is correct |
27 | Correct | 110 ms | 61776 KB | Output is correct |