| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 153362 | junodeveloper | Tents (JOI18_tents) | C++14 | 169 ms | 35776 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int MOD=1e9+7;
int H,W;
int dp[3010][3010];
inline void add(int& a,int b) {
a+=b;a%=MOD;
}
int main() {
scanf("%d%d",&H,&W);
int h,w;
dp[0][0]=1;
for(h=1;h<=H;h++) dp[h][0]=1;
for(w=1;w<=W;w++) dp[0][w]=1;
dp[1][1]=5;
for(h=1;h<=H;h++) dp[h][1]=(h*4+h*(h-1)/2+1)%MOD;
for(w=1;w<=W;w++) dp[1][w]=(w*4+w*(w-1)/2+1)%MOD;
for(h=2;h<=H;h++) {
for(w=2;w<=W;w++) {
add(dp[h][w],dp[h-1][w]);
add(dp[h][w],4ll*w*dp[h-1][w-1]%MOD);
add(dp[h][w],(ll)w*(h-1)*dp[h-2][w-1]%MOD);
add(dp[h][w],(ll)w*(w-1)/2%MOD*dp[h-1][w-2]%MOD);
}
}
printf("%d",(MOD-1+dp[H][W])%MOD);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
