Submission #1151938

#TimeUsernameProblemLanguageResultExecution timeMemory
1151938minggaTents (JOI18_tents)C++20
100 / 100
116 ms70820 KiB
#include "bits/stdc++.h" using namespace std; #define ln "\n" #define pb push_back #define fi first #define se second #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) #define int long long const int mod = 1e9 + 7; const int inf = 2e18; const int N = 3005; int w, h, dp[N][N]; int add(int x, int y) { x += y; if(x >= mod) x -= mod; return x; } int mul(int x, int y) { x %= mod, y %= mod; return (x * y) % mod; } int c2(int x) { int a = x, b = x - 1; if(a % 2) b /= 2; else a /= 2; return mul(a, b); } signed main() { cin.tie(0) -> sync_with_stdio(0); #define task "" if(fopen(task ".INP", "r")) { freopen(task ".INP", "r", stdin); freopen(task ".OUT", "w", stdout); } cin >> w >> h; dp[0][0] = 1; for(int i = 1; i <= w; i++) { dp[i][0] = 1; } for(int i = 1; i <= h; i++) { dp[0][i] = 1; } for(int i = 1; i <= w; i++) { for(int j = 1; j <= h; j++) { dp[i][j] = add(dp[i][j], dp[i - 1][j]); dp[i][j] = add(dp[i][j], mul(dp[i - 1][j - 1], 4 * j)); if(i > 1) dp[i][j] = add(dp[i][j], mul((i - 1) * j, dp[i - 2][j - 1])); if(j > 1) dp[i][j] = add(dp[i][j], mul(c2(j), dp[i - 1][j - 2])); } } cout << (dp[w][h] - 1 + mod) % mod << ln; cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC; }

Compilation message (stderr)

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