제출 #44367

#제출 시각아이디문제언어결과실행 시간메모리
44367choikiwonTents (JOI18_tents)C++17
100 / 100
429 ms36324 KiB
#include<bits/stdc++.h>
using namespace std;

const int mod = 1e9 + 7;

int H, W;

int cc[3010][3010];
int dp(int r, int c) {
    int &ret = cc[r][c];
    if(ret != -1) return ret;
    if(!r || !c) return ret = 1;

    ret = 0;
    ret += dp(r - 1, c);
    ret %= mod;
    if(r >= 1) {
        ret += 1LL * 4 * c % mod * dp(r - 1, c - 1) % mod;
        ret %= mod;
    }
    if(r >= 2) {
        ret += 1LL * (r - 1) * c % mod * dp(r - 2, c - 1) % mod;
        ret %= mod;
    }
    if(c >= 2) {
        ret += 1LL * (c * (c - 1) / 2) * dp(r - 1, c - 2) % mod;
        ret %= mod;
    }
    return ret;
}

int main() {
    scanf("%d %d", &H, &W);

    memset(cc, -1, sizeof(cc));
    printf("%d", dp(H, W) - 1);
}

컴파일 시 표준 에러 (stderr) 메시지

tents.cpp: In function 'int main()':
tents.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &H, &W);
     ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...