# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
56311 |
2018-07-11T04:35:00 Z |
윤교준(#1600) |
Tents (JOI18_tents) |
C++11 |
|
372 ms |
106508 KB |
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const int MAXH = 3005;
const int MAXW = 3005;
int dp[MAXW][MAXH], ds[MAXW][MAXH], dks[MAXW][MAXH];
int H, W;
int main() {
for(int i = 0; i < MAXH; i++) dp[0][i] = dp[i][0] = 1;
for(int i = 0; i < MAXH; i++) ds[0][i] = i+1;
dks[0][0] = 1; for(int i = 1; i < MAXH; i++) dks[0][i] = (dks[0][i-1] + i+1) % MOD;
cin >> H >> W;
for(int w = 1; w <= W; w++) {
for(int h = 1; h <= H; h++) {
int &ret = dp[w][h];
ret = (ll(ds[w-1][h-1]) * w % MOD * 4 + ret) % MOD;
if(1 < h) ret = (ll(dks[w-1][h-2]) * w + ret) % MOD;
if(1 < w) ret = (ll(w) * (w-1) / 2 % MOD * ds[w-2][h-1] + ret) % MOD;
ret = (ret + 1) % MOD;
}
ds[w][0] = 1; for(int j = 1; j <= H; j++) ds[w][j] = (ds[w][j-1] + dp[w][j]) % MOD;
dks[w][0] = 1; for(int j = 1; j <= H; j++) dks[w][j] = (ll(dp[w][j]) * (j+1) + dks[w][j-1]) % MOD;
}
cout << ((dp[W][H] - 1 + MOD) % MOD) << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
12536 KB |
Output is correct |
2 |
Correct |
13 ms |
14052 KB |
Output is correct |
3 |
Correct |
11 ms |
14052 KB |
Output is correct |
4 |
Correct |
13 ms |
14052 KB |
Output is correct |
5 |
Correct |
13 ms |
14744 KB |
Output is correct |
6 |
Correct |
13 ms |
14744 KB |
Output is correct |
7 |
Correct |
12 ms |
14744 KB |
Output is correct |
8 |
Correct |
12 ms |
14744 KB |
Output is correct |
9 |
Correct |
10 ms |
14744 KB |
Output is correct |
10 |
Correct |
15 ms |
14744 KB |
Output is correct |
11 |
Correct |
15 ms |
15196 KB |
Output is correct |
12 |
Correct |
19 ms |
16128 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
12536 KB |
Output is correct |
2 |
Correct |
13 ms |
14052 KB |
Output is correct |
3 |
Correct |
11 ms |
14052 KB |
Output is correct |
4 |
Correct |
13 ms |
14052 KB |
Output is correct |
5 |
Correct |
13 ms |
14744 KB |
Output is correct |
6 |
Correct |
13 ms |
14744 KB |
Output is correct |
7 |
Correct |
12 ms |
14744 KB |
Output is correct |
8 |
Correct |
12 ms |
14744 KB |
Output is correct |
9 |
Correct |
10 ms |
14744 KB |
Output is correct |
10 |
Correct |
15 ms |
14744 KB |
Output is correct |
11 |
Correct |
15 ms |
15196 KB |
Output is correct |
12 |
Correct |
19 ms |
16128 KB |
Output is correct |
13 |
Correct |
26 ms |
27516 KB |
Output is correct |
14 |
Correct |
13 ms |
27516 KB |
Output is correct |
15 |
Correct |
228 ms |
75880 KB |
Output is correct |
16 |
Correct |
33 ms |
75880 KB |
Output is correct |
17 |
Correct |
78 ms |
75880 KB |
Output is correct |
18 |
Correct |
89 ms |
75880 KB |
Output is correct |
19 |
Correct |
360 ms |
82644 KB |
Output is correct |
20 |
Correct |
218 ms |
82644 KB |
Output is correct |
21 |
Correct |
181 ms |
82644 KB |
Output is correct |
22 |
Correct |
169 ms |
82644 KB |
Output is correct |
23 |
Correct |
91 ms |
82644 KB |
Output is correct |
24 |
Correct |
372 ms |
106508 KB |
Output is correct |
25 |
Correct |
286 ms |
106508 KB |
Output is correct |
26 |
Correct |
364 ms |
106508 KB |
Output is correct |
27 |
Correct |
369 ms |
106508 KB |
Output is correct |