제출 #83901

#제출 시각아이디문제언어결과실행 시간메모리
83901RezwanArefin01Tents (JOI18_tents)C++17
100 / 100
187 ms36040 KiB
///usr/bin/g++ -O2 $0 -o ${0%.cpp} && echo "----------" && ./${0%.cpp}; exit;
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii; 

const int N = 3010; 
const int mod = 1e9 + 7; 
const int inv2 = (mod + 1) / 2;

int dp[N][N], H, W; 

int mul(int a, int b) {
    return (ll) a * b % mod; 
}
void add(int &a, int b) {
    a += b; 
    if(a >= mod) a -= mod; 
}

int main() {
    scanf("%d %d", &H, &W);
    for(int w = 0; w <= W; w++) dp[0][w] = 1;
    for(int h = 1; h <= H; h++) {
        dp[h][0] = 1; 
        for(int w = 1; w <= W; w++) {
            dp[h][w] = dp[h - 1][w]; 
            add(dp[h][w], mul(mul(4, w), dp[h - 1][w - 1])); 
            if(w >= 2) add(dp[h][w], mul(mul(w, mul(w - 1, inv2)), dp[h - 1][w - 2])); 
            if(h >= 2) add(dp[h][w], mul(mul(w, h - 1), dp[h - 2][w - 1])); 
        }
    }
    dp[H][W] -= 1; 
    if(dp[H][W] < 0) dp[H][W] += mod; 
    printf("%d\n", dp[H][W]); 
}

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

tents.cpp: In function 'int main()':
tents.cpp:23: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...