답안 #164182

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
164182 2019-11-18T12:48:51 Z mhy908 Tents (JOI18_tents) C++14
100 / 100
162 ms 91132 KB
#include <bits/stdc++.h>
typedef long long LL;
const LL mod=1000000007;
int n, m;
LL dp[5010][5010];
int main()
{
    scanf("%d %d", &n, &m);
    for(int i=0; i<=5000; i++){
        dp[i][0]=1;
        dp[0][i]=1;
    }
    for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
			dp[i][j]=(dp[i-1][j]+4*j*dp[i-1][j-1])%mod;
			if(i>=2)dp[i][j]=(dp[i][j]+(LL)(i-1)*j*dp[i-2][j-1])%mod;
			if(j>=2)dp[i][j]=(dp[i][j]+(LL)j*(j-1)/2*dp[i-1][j-2])%mod;
		}
	}
    printf("%lld", (dp[n][m]+mod-1)%mod);
}

Compilation message

tents.cpp: In function 'int main()':
tents.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 20728 KB Output is correct
2 Correct 18 ms 20732 KB Output is correct
3 Correct 17 ms 20732 KB Output is correct
4 Correct 18 ms 20728 KB Output is correct
5 Correct 19 ms 20856 KB Output is correct
6 Correct 18 ms 20856 KB Output is correct
7 Correct 18 ms 20856 KB Output is correct
8 Correct 18 ms 20856 KB Output is correct
9 Correct 18 ms 20728 KB Output is correct
10 Correct 18 ms 21112 KB Output is correct
11 Correct 19 ms 20728 KB Output is correct
12 Correct 19 ms 21496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 20728 KB Output is correct
2 Correct 18 ms 20732 KB Output is correct
3 Correct 17 ms 20732 KB Output is correct
4 Correct 18 ms 20728 KB Output is correct
5 Correct 19 ms 20856 KB Output is correct
6 Correct 18 ms 20856 KB Output is correct
7 Correct 18 ms 20856 KB Output is correct
8 Correct 18 ms 20856 KB Output is correct
9 Correct 18 ms 20728 KB Output is correct
10 Correct 18 ms 21112 KB Output is correct
11 Correct 19 ms 20728 KB Output is correct
12 Correct 19 ms 21496 KB Output is correct
13 Correct 19 ms 20728 KB Output is correct
14 Correct 18 ms 20720 KB Output is correct
15 Correct 110 ms 64484 KB Output is correct
16 Correct 23 ms 23544 KB Output is correct
17 Correct 38 ms 30456 KB Output is correct
18 Correct 44 ms 32892 KB Output is correct
19 Correct 123 ms 71672 KB Output is correct
20 Correct 102 ms 61436 KB Output is correct
21 Correct 75 ms 47480 KB Output is correct
22 Correct 71 ms 47120 KB Output is correct
23 Correct 49 ms 35448 KB Output is correct
24 Correct 162 ms 91132 KB Output is correct
25 Correct 127 ms 72944 KB Output is correct
26 Correct 145 ms 80632 KB Output is correct
27 Correct 157 ms 88316 KB Output is correct