# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
153362 | 2019-09-13T17:04:39 Z | junodeveloper | Tents (JOI18_tents) | C++14 | 169 ms | 35776 KB |
#include <bits/stdc++.h> #define sz(x) ((int)x.size()) #define all(x) (x).begin(), (x).end() #define fi first #define se second using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const int MOD=1e9+7; int H,W; int dp[3010][3010]; inline void add(int& a,int b) { a+=b;a%=MOD; } int main() { scanf("%d%d",&H,&W); int h,w; dp[0][0]=1; for(h=1;h<=H;h++) dp[h][0]=1; for(w=1;w<=W;w++) dp[0][w]=1; dp[1][1]=5; for(h=1;h<=H;h++) dp[h][1]=(h*4+h*(h-1)/2+1)%MOD; for(w=1;w<=W;w++) dp[1][w]=(w*4+w*(w-1)/2+1)%MOD; for(h=2;h<=H;h++) { for(w=2;w<=W;w++) { add(dp[h][w],dp[h-1][w]); add(dp[h][w],4ll*w*dp[h-1][w-1]%MOD); add(dp[h][w],(ll)w*(h-1)*dp[h-2][w-1]%MOD); add(dp[h][w],(ll)w*(w-1)/2%MOD*dp[h-1][w-2]%MOD); } } printf("%d",(MOD-1+dp[H][W])%MOD); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 504 KB | Output is correct |
4 | Correct | 3 ms | 1144 KB | Output is correct |
5 | Correct | 3 ms | 632 KB | Output is correct |
6 | Correct | 3 ms | 1272 KB | Output is correct |
7 | Correct | 3 ms | 760 KB | Output is correct |
8 | Correct | 3 ms | 1400 KB | Output is correct |
9 | Correct | 2 ms | 888 KB | Output is correct |
10 | Correct | 4 ms | 1660 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 5 ms | 1828 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 504 KB | Output is correct |
4 | Correct | 3 ms | 1144 KB | Output is correct |
5 | Correct | 3 ms | 632 KB | Output is correct |
6 | Correct | 3 ms | 1272 KB | Output is correct |
7 | Correct | 3 ms | 760 KB | Output is correct |
8 | Correct | 3 ms | 1400 KB | Output is correct |
9 | Correct | 2 ms | 888 KB | Output is correct |
10 | Correct | 4 ms | 1660 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 5 ms | 1828 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 9 ms | 9592 KB | Output is correct |
15 | Correct | 116 ms | 32936 KB | Output is correct |
16 | Correct | 10 ms | 2680 KB | Output is correct |
17 | Correct | 28 ms | 7976 KB | Output is correct |
18 | Correct | 36 ms | 11000 KB | Output is correct |
19 | Correct | 139 ms | 34620 KB | Output is correct |
20 | Correct | 106 ms | 29156 KB | Output is correct |
21 | Correct | 72 ms | 19800 KB | Output is correct |
22 | Correct | 75 ms | 22152 KB | Output is correct |
23 | Correct | 49 ms | 19676 KB | Output is correct |
24 | Correct | 169 ms | 35776 KB | Output is correct |
25 | Correct | 130 ms | 30772 KB | Output is correct |
26 | Correct | 147 ms | 33496 KB | Output is correct |
27 | Correct | 161 ms | 34728 KB | Output is correct |