# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1033977 | 2024-07-25T08:16:06 Z | vjudge1 | Tents (JOI18_tents) | C++17 | 76 ms | 70996 KB |
// (JOI 2017/2018) Spring Training Camp/Qualifying Trial // Problem Tents #include <bits/stdc++.h> #define ll long long #define ld long double #define el cout << '\n' #define f1(i,n) for(ll i=1;i<=n;i++) #define __file_name "" using namespace std; const ll maxn = 3005, inf=1e18, mod=1e9+7; ll h,w,dp[maxn][maxn]; int main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); if(fopen(__file_name ".inp", "r")){ freopen(__file_name ".inp","r",stdin); freopen(__file_name ".out","w",stdout); } // code here cin >> h >> w; dp[1][1] = 5; f1(i,h) dp[i][0] = 1; f1(i, w) dp[0][i] = 1; dp[0][0] = 1; // f1(i,h) dp[i][1] = (4 * i + i*(i-1)/2 + 1) % mod; // f1(j,w) dp[1][j] = (4 * j + j*(j-1)/2 + 1) % mod; for(ll i=1;i<=h;i++) for(ll j=1;j<=w;j++){ dp[i][j] = dp[i-1][j]; dp[i][j] += dp[i-1][j-1] * 4 * j; if(i >= 2) dp[i][j] += dp[i-2][j-1] * j * (i-1) % mod; if(j >= 2) dp[i][j] += dp[i-1][j-2] * j * (j-1) / 2 % mod; dp[i][j] %= mod; } cout << (dp[h][w] + mod - 1) % mod; return 0; } /* Code by: Nguyen Viet Trung Nhan Cau Giay Secondary School */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 4700 KB | Output is correct |
5 | Correct | 1 ms | 2396 KB | Output is correct |
6 | Correct | 1 ms | 3164 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 3164 KB | Output is correct |
9 | Correct | 1 ms | 2648 KB | Output is correct |
10 | Correct | 1 ms | 4956 KB | Output is correct |
11 | Correct | 0 ms | 2396 KB | Output is correct |
12 | Correct | 2 ms | 3836 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 4700 KB | Output is correct |
5 | Correct | 1 ms | 2396 KB | Output is correct |
6 | Correct | 1 ms | 3164 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 3164 KB | Output is correct |
9 | Correct | 1 ms | 2648 KB | Output is correct |
10 | Correct | 1 ms | 4956 KB | Output is correct |
11 | Correct | 0 ms | 2396 KB | Output is correct |
12 | Correct | 2 ms | 3836 KB | Output is correct |
13 | Correct | 1 ms | 344 KB | Output is correct |
14 | Correct | 4 ms | 11356 KB | Output is correct |
15 | Correct | 53 ms | 55528 KB | Output is correct |
16 | Correct | 3 ms | 4696 KB | Output is correct |
17 | Correct | 10 ms | 13744 KB | Output is correct |
18 | Correct | 14 ms | 17960 KB | Output is correct |
19 | Correct | 58 ms | 63316 KB | Output is correct |
20 | Correct | 47 ms | 51096 KB | Output is correct |
21 | Correct | 30 ms | 34380 KB | Output is correct |
22 | Correct | 35 ms | 36180 KB | Output is correct |
23 | Correct | 20 ms | 28252 KB | Output is correct |
24 | Correct | 76 ms | 70996 KB | Output is correct |
25 | Correct | 60 ms | 61264 KB | Output is correct |
26 | Correct | 66 ms | 66612 KB | Output is correct |
27 | Correct | 72 ms | 68944 KB | Output is correct |