답안 #370924

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
370924 2021-02-25T05:24:04 Z mjhmjh1104 Tents (JOI18_tents) C++14
100 / 100
503 ms 36076 KB
#include <cstdio>
#include <algorithm>
using namespace std;

const int MOD = 1e9 + 7;

int dp[3006][3006];

int f(int x, int y) {
    if (dp[x][y] + 1) return dp[x][y];
    if (!x || !y) return dp[x][y] = 1;
    if (x == 1) return dp[x][y] = (1 + 4LL * y % MOD + 1LL * y * (y - 1) / 2 % MOD) % MOD;
    if (y == 1) return dp[x][y] = (1 + 4LL * x % MOD + 1LL * x * (x - 1) / 2 % MOD) % MOD;
    return dp[x][y] = (f(x, y - 1) + 4LL * x % MOD * f(x - 1, y - 1) + 1LL * x * (y - 1) % MOD * f(x - 1, y - 2) % MOD + 1LL * x * (x - 1) / 2 % MOD * f(x - 2, y - 1) % MOD) % MOD;
}

int h, w;

int main() {
    fill(dp[0], dp[3005] + 3006, -1);
    scanf("%d%d", &h, &w);
    printf("%d", (f(h, w) + MOD - 1) % MOD);
}

Compilation message

tents.cpp: In function 'int main()':
tents.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |     scanf("%d%d", &h, &w);
      |     ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 35820 KB Output is correct
2 Correct 27 ms 35712 KB Output is correct
3 Correct 23 ms 35712 KB Output is correct
4 Correct 23 ms 35692 KB Output is correct
5 Correct 23 ms 35692 KB Output is correct
6 Correct 23 ms 35692 KB Output is correct
7 Correct 25 ms 35712 KB Output is correct
8 Correct 23 ms 35820 KB Output is correct
9 Correct 23 ms 35692 KB Output is correct
10 Correct 23 ms 35692 KB Output is correct
11 Correct 23 ms 35692 KB Output is correct
12 Correct 26 ms 35692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 35820 KB Output is correct
2 Correct 27 ms 35712 KB Output is correct
3 Correct 23 ms 35712 KB Output is correct
4 Correct 23 ms 35692 KB Output is correct
5 Correct 23 ms 35692 KB Output is correct
6 Correct 23 ms 35692 KB Output is correct
7 Correct 25 ms 35712 KB Output is correct
8 Correct 23 ms 35820 KB Output is correct
9 Correct 23 ms 35692 KB Output is correct
10 Correct 23 ms 35692 KB Output is correct
11 Correct 23 ms 35692 KB Output is correct
12 Correct 26 ms 35692 KB Output is correct
13 Correct 23 ms 35692 KB Output is correct
14 Correct 22 ms 35712 KB Output is correct
15 Correct 262 ms 35972 KB Output is correct
16 Correct 37 ms 35820 KB Output is correct
17 Correct 70 ms 35820 KB Output is correct
18 Correct 78 ms 35820 KB Output is correct
19 Correct 310 ms 35820 KB Output is correct
20 Correct 258 ms 35948 KB Output is correct
21 Correct 191 ms 35820 KB Output is correct
22 Correct 161 ms 35948 KB Output is correct
23 Correct 46 ms 35692 KB Output is correct
24 Correct 503 ms 36076 KB Output is correct
25 Correct 350 ms 35952 KB Output is correct
26 Correct 400 ms 35948 KB Output is correct
27 Correct 469 ms 35948 KB Output is correct