# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
57035 | cki86201 | Tents (JOI18_tents) | C++11 | 127 ms | 72000 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) x.begin(), x.end()
const int MOD = 1e9 + 7;
ll d[3030][3030];
void solve(){
int n, m; scanf("%d%d", &n, &m);
rep(i, 3030) d[i][0] = d[0][i] = 1;
for(int i=1;i<=n;i++) {
for(int j=1;j<=m;j++) {
d[i][j] = d[i-1][j] + 4LL * d[i-1][j-1] * j;
if(j >= 2) d[i][j] += j * (j-1) / 2 * d[i-1][j-2];
if(i >= 2) d[i][j] += j * (i-1) * d[i-2][j-1];
d[i][j] %= MOD;
}
}
printf("%lld\n", (d[n][m] + MOD - 1) % MOD);
}
int main(){
int Tc = 1; //scanf("%d", &Tc);
for(int tc=1;tc<=Tc;tc++){
solve();
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |