제출 #50485

#제출 시각아이디문제언어결과실행 시간메모리
50485top34051Tents (JOI18_tents)C++17
0 / 100
2047 ms77664 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long const int maxn = 3005; const ll mod = 1e9+7; int n,m; unordered_map<int,unordered_map<int,unordered_map<int,ll>>> dp; ll add(ll x, ll y) { return ((x+y)%mod + mod)%mod; } ll mul(ll x, ll y) { return ((x*y)%mod + mod)%mod; } ll comb(ll x) { return ((x*(x-1)/2)%mod + mod)%mod; } ll f(int x, int need, int free) { if(x==n+1) return 1; if(!dp[x][need][free]) { ll res = 0; //nothing res = add(res, f(x+1,need,free)); //point to south if(free>=1) res = add(res, mul(free, f(x+1,need+1,free-1))); //point to north if(free>=1) res = add(res, mul(free, f(x+1,need,free-1))); if(need>=1) res = add(res, mul(need, f(x+1,need-1,free))); //point to west and east if(free>=1) res = add(res, mul(free, f(x+1,need,free-1))); if(free>=1) res = add(res, mul(free, f(x+1,need,free-1))); if(free>=2) res = add(res, mul(comb(free), f(x+1,need,free-2))); dp[x][need][free] = res; } return dp[x][need][free]; } int main() { scanf("%d%d",&n,&m); printf("%lld",add(f(1,0,m),-1)); }

컴파일 시 표준 에러 (stderr) 메시지

tents.cpp: In function 'int main()':
tents.cpp:37:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&n,&m);
         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...