#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x) cerr<< #x <<" = "<< x<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N=3003;
int p[N],dp[N][N],n,m;
int mod(ll x){return (x%INF);}
int rec(int x,int y){
if(!x)return 1;
int &ret=dp[x][y];
if(~ret)return ret;
ret=rec(x-1,y);
if(y>=2)ret=mod(ret+rec(x-1,y-2)*1LL*p[y]);
if(y)ret=mod(ret+rec(x-1,y-1)*4LL*y);
if(y and x>=2)ret=mod(ret+rec(x-2,y-1)*1LL*y*(x-1));
return ret;
}
int main(){
//freopen("file.in", "r", stdin);
for(int i=1;i<N;i++)p[i]=(i*(i-1))/2;
scanf("%d%d",&n,&m);
memset(dp,-1,sizeof dp);
printf("%d\n",rec(n,m)-1);
return 0;
}
Compilation message
tents.cpp: In function 'int main()':
tents.cpp:36:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
36 | scanf("%d%d",&n,&m);
| ~~~~~^~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
35564 KB |
Output is correct |
2 |
Correct |
18 ms |
35564 KB |
Output is correct |
3 |
Correct |
19 ms |
35692 KB |
Output is correct |
4 |
Correct |
18 ms |
35692 KB |
Output is correct |
5 |
Correct |
18 ms |
35564 KB |
Output is correct |
6 |
Correct |
20 ms |
35692 KB |
Output is correct |
7 |
Correct |
18 ms |
35564 KB |
Output is correct |
8 |
Correct |
18 ms |
35692 KB |
Output is correct |
9 |
Correct |
18 ms |
35600 KB |
Output is correct |
10 |
Correct |
19 ms |
35692 KB |
Output is correct |
11 |
Correct |
18 ms |
35564 KB |
Output is correct |
12 |
Correct |
20 ms |
35692 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
35564 KB |
Output is correct |
2 |
Correct |
18 ms |
35564 KB |
Output is correct |
3 |
Correct |
19 ms |
35692 KB |
Output is correct |
4 |
Correct |
18 ms |
35692 KB |
Output is correct |
5 |
Correct |
18 ms |
35564 KB |
Output is correct |
6 |
Correct |
20 ms |
35692 KB |
Output is correct |
7 |
Correct |
18 ms |
35564 KB |
Output is correct |
8 |
Correct |
18 ms |
35692 KB |
Output is correct |
9 |
Correct |
18 ms |
35600 KB |
Output is correct |
10 |
Correct |
19 ms |
35692 KB |
Output is correct |
11 |
Correct |
18 ms |
35564 KB |
Output is correct |
12 |
Correct |
20 ms |
35692 KB |
Output is correct |
13 |
Correct |
18 ms |
35564 KB |
Output is correct |
14 |
Correct |
20 ms |
35820 KB |
Output is correct |
15 |
Correct |
158 ms |
35820 KB |
Output is correct |
16 |
Correct |
20 ms |
35692 KB |
Output is correct |
17 |
Correct |
31 ms |
35692 KB |
Output is correct |
18 |
Correct |
49 ms |
35692 KB |
Output is correct |
19 |
Correct |
201 ms |
35948 KB |
Output is correct |
20 |
Correct |
141 ms |
35948 KB |
Output is correct |
21 |
Correct |
90 ms |
35820 KB |
Output is correct |
22 |
Correct |
100 ms |
35820 KB |
Output is correct |
23 |
Correct |
67 ms |
36076 KB |
Output is correct |
24 |
Correct |
267 ms |
35948 KB |
Output is correct |
25 |
Correct |
179 ms |
35820 KB |
Output is correct |
26 |
Correct |
211 ms |
35948 KB |
Output is correct |
27 |
Correct |
238 ms |
35948 KB |
Output is correct |