답안 #129460

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
129460 2019-07-12T09:17:23 Z dndhk Tents (JOI18_tents) C++14
100 / 100
98 ms 70872 KB
#include <bits/stdc++.h>

#define pb push_back
#define all(v) ((v).begin(), (v).end())
#define sortv(v) sort(all(v))
#define sz(v) ((int)(v).size())
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define umax(a, b) (a)=max((a), (b))
#define umin(a, b) (a)=min((a), (b))
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define rep(i,n) FOR(i,1,n)
#define rep0(i,n) FOR(i,0,(int)(n)-1)
#define FI first
#define SE second
#define INF 2000000000
#define INFLL 1000000000000000000LL


using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll DIV = 1000000007;
const int MAX_N = 3000;

int H, W;
ll DP[MAX_N+1][MAX_N+1];

int main(){
	scanf("%d%d", &H, &W);
	for(int i=0; i<=W; i++){
		DP[0][i] = 1;
	}
	for(int i=1; i<=H; i++){
		DP[i][0] = 1;
		for(int j=1; j<=W; j++){
			DP[i][j] = (DP[i-1][j] + DP[i-1][j-1] * (ll)(4 * j) + (i>=2 ? DP[i-2][j-1] : 0)* (ll)j * (ll)(i-1) + (j>=2 ? DP[i-1][j-2] : 0) * (ll)j * (ll)(j-1) / 2 ) %DIV;
			//cout<<i<<" "<<j<<" "<<DP[i][j]<<endl;
		}
	}
	cout<<(DP[H][W] + DIV - 1)%DIV;
	return 0;
}

Compilation message

tents.cpp: In function 'int main()':
tents.cpp:31:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &H, &W);
  ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 1 ms 1144 KB Output is correct
5 Correct 2 ms 760 KB Output is correct
6 Correct 3 ms 1400 KB Output is correct
7 Correct 2 ms 888 KB Output is correct
8 Correct 3 ms 1400 KB Output is correct
9 Correct 2 ms 760 KB Output is correct
10 Correct 3 ms 1784 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 4 ms 2300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 1 ms 1144 KB Output is correct
5 Correct 2 ms 760 KB Output is correct
6 Correct 3 ms 1400 KB Output is correct
7 Correct 2 ms 888 KB Output is correct
8 Correct 3 ms 1400 KB Output is correct
9 Correct 2 ms 760 KB Output is correct
10 Correct 3 ms 1784 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 4 ms 2300 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 9 ms 9720 KB Output is correct
15 Correct 65 ms 55160 KB Output is correct
16 Correct 6 ms 4112 KB Output is correct
17 Correct 17 ms 12920 KB Output is correct
18 Correct 21 ms 17144 KB Output is correct
19 Correct 75 ms 63096 KB Output is correct
20 Correct 61 ms 50936 KB Output is correct
21 Correct 41 ms 33820 KB Output is correct
22 Correct 42 ms 35448 KB Output is correct
23 Correct 30 ms 27120 KB Output is correct
24 Correct 98 ms 70872 KB Output is correct
25 Correct 75 ms 61180 KB Output is correct
26 Correct 93 ms 66524 KB Output is correct
27 Correct 87 ms 68956 KB Output is correct