Submission #641092

#TimeUsernameProblemLanguageResultExecution timeMemory
641092ghostwriterTents (JOI18_tents)C++14
100 / 100
123 ms63236 KiB
#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 (stderr)

tents.cpp: In function 'int main()':
tents.cpp:24:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
tents.cpp:44:5: note: in expansion of macro 'FOR'
   44 |     FOR(i, 0, h)
      |     ^~~
tents.cpp:24:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
tents.cpp:45:5: note: in expansion of macro 'FOR'
   45 |     FOR(j, 0, w)
      |     ^~~
tents.cpp:24:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
tents.cpp:48:5: note: in expansion of macro 'FOR'
   48 |     FOR(i, 0, max(h, w))
      |     ^~~
tents.cpp:24:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
tents.cpp:49:5: note: in expansion of macro 'FOR'
   49 |     FOR(j, 0, i)
      |     ^~~
tents.cpp:24:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
tents.cpp:54:5: note: in expansion of macro 'FOR'
   54 |     FOR(i, 1, max(h, w)) {
      |     ^~~
tents.cpp:24:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
tents.cpp:58:5: note: in expansion of macro 'FOR'
   58 |     FOR(i, 0, min(h, w / 2)) {
      |     ^~~
tents.cpp:24:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
tents.cpp:61:6: note: in expansion of macro 'FOR'
   61 |      FOR(j, 0, min(rmy, rmx / 2)) {
      |      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...