Submission #421364

#TimeUsernameProblemLanguageResultExecution timeMemory
421364juggernautTents (JOI18_tents)C++17
100 / 100
498 ms71136 KiB
#include<bits/stdc++.h> #define fr first #define sc second using namespace std; void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);} typedef long long ll; #define USING_ORDERED_SET 0 #if USING_ORDERED_SET #include<bits/extc++.h> using namespace __gnu_pbds; template<class T>using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; #endif template<class T>void umax(T &a,T b){if(a<b)a=b;} template<class T>void umin(T &a,T b){if(b<a)a=b;} #ifdef IOI2021SG #define printl(args...)printf(args) #else #define printl(args...)((void)0) #endif ll dp[3005][3005]; ll mod=1e9+7; inline ll add(ll a,ll b){ return (a+b)%mod; } inline ll mult(ll a,ll b){ return (a*b)%mod; } ll go(int n,int m){ if(n==1)return 4*m+m*(m-1)/2+1; if(m==1)return 4*n+n*(n-1)/2+1; if(n==0||m==0)return 1; if(n<0||m<0)return 0; ll &res=dp[n][m]; if(~res)return res; res=0; res=add(res,go(n-1,m)); res=add(res,mult(4*m,go(n-1,m-1))); res=add(res,mult(go(n-1,m-2),m*(m-1)/2)); res=add(res,mult(go(n-2,m-1),m*(n-1))); return res; } int main(){ memset(dp,-1,sizeof dp); int n,m; scanf("%d%d",&n,&m); if(n>m)swap(n,m); ll ans=go(n,m); if(ans==0)ans=mod-1; else ans--; printf("%lld",ans); }

Compilation message (stderr)

tents.cpp: In function 'void usaco(std::string)':
tents.cpp:5:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tents.cpp:5:66: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tents.cpp: In function 'int main()':
tents.cpp:45:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |     scanf("%d%d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...