Submission #1055049

#TimeUsernameProblemLanguageResultExecution timeMemory
1055049manhlinh1501Tents (JOI18_tents)C++17
100 / 100
152 ms71344 KiB
#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(r < 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 (stderr)

tents.cpp: In function 'int main()':
tents.cpp:36:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         freopen(TASK ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
tents.cpp:37:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |         freopen(TASK ".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...