# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
204522 |
2020-02-26T08:25:43 Z |
egekabas |
Tents (JOI18_tents) |
C++14 |
|
397 ms |
59016 KB |
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
const ll mod = 1e9+7;
ll n, m;
ll dp[3009][3009];
ll f(ll x, ll y){
if(x < 0 || y < 0) return 0;
if(dp[x][y] != 0) return dp[x][y];
if(x == 0 || y == 0) return dp[x][y] = 1;
dp[x][y] = y*(y-1)/2*f(x-1, y-2)%mod + y*(x-1)*f(x-2, y-1)%mod + 4*y*f(x-1, y-1)%mod + f(x-1, y);
dp[x][y] %= mod;
return dp[x][y];
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
cin >> n >> m;
cout << f(n, m)-1 << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
504 KB |
Output is correct |
4 |
Correct |
6 ms |
1144 KB |
Output is correct |
5 |
Correct |
5 ms |
632 KB |
Output is correct |
6 |
Correct |
6 ms |
1400 KB |
Output is correct |
7 |
Correct |
5 ms |
764 KB |
Output is correct |
8 |
Correct |
6 ms |
1528 KB |
Output is correct |
9 |
Correct |
5 ms |
888 KB |
Output is correct |
10 |
Correct |
7 ms |
1784 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
8 ms |
2040 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
504 KB |
Output is correct |
4 |
Correct |
6 ms |
1144 KB |
Output is correct |
5 |
Correct |
5 ms |
632 KB |
Output is correct |
6 |
Correct |
6 ms |
1400 KB |
Output is correct |
7 |
Correct |
5 ms |
764 KB |
Output is correct |
8 |
Correct |
6 ms |
1528 KB |
Output is correct |
9 |
Correct |
5 ms |
888 KB |
Output is correct |
10 |
Correct |
7 ms |
1784 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
8 ms |
2040 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
11 ms |
9848 KB |
Output is correct |
15 |
Correct |
277 ms |
47352 KB |
Output is correct |
16 |
Correct |
7 ms |
1656 KB |
Output is correct |
17 |
Correct |
23 ms |
6904 KB |
Output is correct |
18 |
Correct |
49 ms |
13692 KB |
Output is correct |
19 |
Correct |
293 ms |
53368 KB |
Output is correct |
20 |
Correct |
219 ms |
42360 KB |
Output is correct |
21 |
Correct |
109 ms |
25636 KB |
Output is correct |
22 |
Correct |
158 ms |
30840 KB |
Output is correct |
23 |
Correct |
125 ms |
26616 KB |
Output is correct |
24 |
Correct |
397 ms |
59016 KB |
Output is correct |
25 |
Correct |
285 ms |
49420 KB |
Output is correct |
26 |
Correct |
330 ms |
54776 KB |
Output is correct |
27 |
Correct |
368 ms |
57080 KB |
Output is correct |