Submission #392940

#TimeUsernameProblemLanguageResultExecution timeMemory
392940cpp219Tents (JOI18_tents)C++14
100 / 100
421 ms71376 KiB
#include<bits/stdc++.h> #define ll long long #define ld long double #define fs first #define sc second using namespace std; typedef pair<ll,ll> LL; const ll N = 3e3 + 9; const ll mod = 1e9 + 7; ll x,y; ll dp[N][N]; ll f(ll n,ll m){ if (n*m == 0) return m < y; if (dp[n][m] != -1) return dp[n][m]; ll ans = 0; if (m >= 2) ans = (ans + f(n - 1,m - 2)*m*(m - 1)/2)%mod; ans = (ans + 4*m*f(n - 1,m - 1) + f(n - 1,m))%mod; if (n >= 2) ans = (ans + f(n - 2,m - 1)*m*(n - 1))%mod; return dp[n][m] = ans; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "tst" if (fopen(task".inp","r")){ freopen(task".inp","r",stdin); //freopen(task".out","w",stdout); } cin>>x>>y; memset(dp,-1,sizeof(dp)); cout<<f(x,y); }

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(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...