Submission #1065477

#TimeUsernameProblemLanguageResultExecution timeMemory
1065477phongTents (JOI18_tents)C++17
100 / 100
195 ms71300 KiB
#include<bits/stdc++.h> #define ll long long #define int long long const int nmax = 3e3 + 5, N = 1e6; const ll oo = 1e9 + 1, base = 311; const int lg = 19, M = 10; const ll mod = 1e9 + 7, mod2 = 1e9 + 5277; #define pii pair<int, int> #define fi first #define se second #define endl "\n" #define debug(a, n) for(int i = 1; i <= n; ++i) cout << a[i] << ' '; cout << "\n"; using namespace std; int n, m, dp[nmax][nmax]; ll mul(ll a, ll b){ return a * b % mod; } ll calc(int n, int m){ if(n == 0 || m == 0) return 1; if(n < 0 || m < 0) return 0; if(dp[n][m] != -1) return dp[n][m]; ll &res = dp[n][m]; res = calc(n - 1, m); if(m >= 2){ res += mul(calc(n - 1, m - 2), 1ll * m * (m - 1) / 2); res %= mod; } if(n >= 2){ res += mul(calc(n - 2, m - 1), 1ll * (n - 1) * m); res %= mod; } res += mul(calc(n - 1, m - 1) * 4, m); res %= mod; return res; } main(){ ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); // freopen("code.inp", "r", stdin); // freopen("code.out", "w", stdout); cin >> n >> m; memset(dp, -1, sizeof dp); cout << calc(n, m) - 1; } /* 3 1 */

Compilation message (stderr)

tents.cpp:38:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   38 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...