제출 #1033977

#제출 시각아이디문제언어결과실행 시간메모리
1033977vjudge1Tents (JOI18_tents)C++17
100 / 100
76 ms70996 KiB
// (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
*/

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

tents.cpp: In function 'int main()':
tents.cpp:18:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen(__file_name ".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tents.cpp:19:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         freopen(__file_name ".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...