#include <bits/stdc++.h>
using namespace std;
#define int long long
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0);
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
#define gg exit(0);
const int N=3010,
M=1000000007;
int m,n;
int f[N][N];
void add(int &a,int b){
a+=b; a%=M;
}
main(){
#define task "1"
//freopen(task".inp","r",stdin);
//freopen(task".out","w",stdout);
m=in,n=in;
forinc(i,0,m) forinc(j,0,n) if(i>0 && j>0){
add(f[i][j],f[i-1][j]);
add(f[i][j],f[i-1][j-1]*j*4);
if(i>1 && j>0) add(f[i][j],f[i-2][j-1]*(i-1)*j);
if(j>1 && i>0) add(f[i][j],f[i-1][j-2]*j*(j-1)/2);
} else f[i][j]=1;
cout<<(f[m][n]-1+M)%M;
}
Compilation message
tents.cpp:33:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
512 KB |
Output is correct |
4 |
Correct |
5 ms |
1152 KB |
Output is correct |
5 |
Correct |
5 ms |
768 KB |
Output is correct |
6 |
Correct |
5 ms |
1408 KB |
Output is correct |
7 |
Correct |
5 ms |
896 KB |
Output is correct |
8 |
Correct |
5 ms |
1408 KB |
Output is correct |
9 |
Correct |
5 ms |
768 KB |
Output is correct |
10 |
Correct |
6 ms |
1792 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
7 ms |
2304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
512 KB |
Output is correct |
4 |
Correct |
5 ms |
1152 KB |
Output is correct |
5 |
Correct |
5 ms |
768 KB |
Output is correct |
6 |
Correct |
5 ms |
1408 KB |
Output is correct |
7 |
Correct |
5 ms |
896 KB |
Output is correct |
8 |
Correct |
5 ms |
1408 KB |
Output is correct |
9 |
Correct |
5 ms |
768 KB |
Output is correct |
10 |
Correct |
6 ms |
1792 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
7 ms |
2304 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
9 ms |
9728 KB |
Output is correct |
15 |
Correct |
96 ms |
55160 KB |
Output is correct |
16 |
Correct |
11 ms |
4096 KB |
Output is correct |
17 |
Correct |
25 ms |
12928 KB |
Output is correct |
18 |
Correct |
30 ms |
17144 KB |
Output is correct |
19 |
Correct |
109 ms |
62944 KB |
Output is correct |
20 |
Correct |
88 ms |
50936 KB |
Output is correct |
21 |
Correct |
63 ms |
33784 KB |
Output is correct |
22 |
Correct |
61 ms |
35452 KB |
Output is correct |
23 |
Correct |
40 ms |
27128 KB |
Output is correct |
24 |
Correct |
144 ms |
71068 KB |
Output is correct |
25 |
Correct |
109 ms |
61304 KB |
Output is correct |
26 |
Correct |
124 ms |
66808 KB |
Output is correct |
27 |
Correct |
134 ms |
69112 KB |
Output is correct |