# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1033977 | vjudge1 | Tents (JOI18_tents) | C++17 | 76 ms | 70996 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// (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) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |