# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
257908 |
2020-08-05T04:08:19 Z |
YJU |
Tents (JOI18_tents) |
C++14 |
|
1 ms |
384 KB |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll MOD=1e9+7;
const ll N=2e3+5;
const ld pi=3.14159265359;
const ll INF=(1LL<<62);
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define setp setprecision
#define lwb lower_bound
#define SZ(a) (ll)a.size()
ll n,m,dp[N][N],p[N],rp[N];
ll po(ll base,ll ti){
if(ti==0)return 1;
ll tmp=po(base,ti/2);
if(ti&1)return tmp*tmp%MOD*base%MOD;
return tmp*tmp%MOD;
}
ll C(ll k,ll L){
return (k>L?0:p[L]*rp[k]%MOD*rp[L-k]%MOD);
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>n>>m;
REP(i,n+1)dp[i][0]=1;
REP(i,m+1)dp[0][i]=1;
p[0]=rp[0]=1;REP1(i,N-1)p[i]=i*p[i-1]%MOD,rp[i]=po(p[i],MOD-2);
REP1(i,n)REP1(j,m){
dp[i][j]=((i*4*j%MOD*dp[i-1][j-1])%MOD+(C(2,i)*j%MOD*dp[i-2][j-1])%MOD+(C(2,j)*i%MOD*dp[i-1][j-2])%MOD)%MOD;
}
cout<<dp[n][m]<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |