Submission #338017

#TimeUsernameProblemLanguageResultExecution timeMemory
338017BeanZTents (JOI18_tents)C++14
100 / 100
413 ms71404 KiB
// 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 (stderr)

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