Submission #1033966

#TimeUsernameProblemLanguageResultExecution timeMemory
1033966vjudge1Tents (JOI18_tents)C++14
100 / 100
93 ms70844 KiB
#pragma GCC optimize("O3,unroll-loops") #include <bits/stdc++.h> using namespace std; #define name "aaaaaa" using ll = long long; using pll = pair<ll, ll>; using ld = long double; void file(){ ios_base::sync_with_stdio(0); cin.tie(0); if(fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); } } const int maxn = 3e3 + 5; const ll mod = 1e9 + 7; ll dp[maxn][maxn]; void solve (){ int n, m; cin >> n >> m; for(int i = 0; i < maxn; i++){ dp[0][i] = 1; dp[i][0] = 1; } for(ll i = 1; i <= n; i++){ for(ll j = 1; j <= m; j++){ dp[i][j] += dp[i - 1][j]; dp[i][j] += dp[i - 1][j - 1] * 4 * j % mod; if(j >= 2) dp[i][j] += dp[i - 1][j - 2] * (j * (j - 1) / 2 % mod) % mod; if(i >= 2) dp[i][j] += j * (i - 1) % mod * dp[i - 2][j - 1] % mod; dp[i][j] %= mod; } } dp[n][m]--; if(dp[n][m] < 0) dp[n][m] += mod; cout << dp[n][m]; } int main(){ file(); int t = 1; //cin >> t; while(t--){ solve(); } }

Compilation message (stderr)

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