답안 #1034071

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1034071 2024-07-25T09:29:03 Z BuiDucManh123 Tents (JOI18_tents) C++14
100 / 100
61 ms 82772 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define taskname ""
using namespace std;
const int mod=1e9+7;
ll n,m,i,j,dp[5009][5009];
int main() {
	if (fopen(taskname".inp","r")) {
		freopen(taskname".inp","r",stdin);
		freopen(taskname".out","w",stdout);
	}
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    cin>>n>>m;
    dp[0][0]=1;
    for(i=1;i<=m;i++)
        dp[0][i]=1;
    for(i=1;i<=n;i++)
    for(j=0;j<=m;j++){
        //TH1:
        dp[i][j]=dp[i-1][j];
        //TH2:
        if(j>=2) dp[i][j]+=dp[i-1][j-2]*j*(j-1)/2;
        //TH3:
        dp[i][j]+=dp[i-1][j-1]*j*4;
        if(i>=2) dp[i][j]+=dp[i-2][j-1]*j*(i-1);
        dp[i][j]%=mod;
    }cout<<(dp[n][m]+mod-1)%mod;
	return 0;
}

Compilation message

tents.cpp: In function 'int main()':
tents.cpp:15:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   freopen(taskname".inp","r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
tents.cpp:16:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   freopen(taskname".out","w",stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 1112 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 1 ms 972 KB Output is correct
8 Correct 1 ms 1372 KB Output is correct
9 Correct 0 ms 860 KB Output is correct
10 Correct 1 ms 1884 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 2140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 1112 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 1 ms 972 KB Output is correct
8 Correct 1 ms 1372 KB Output is correct
9 Correct 0 ms 860 KB Output is correct
10 Correct 1 ms 1884 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 2140 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 3 ms 9820 KB Output is correct
15 Correct 36 ms 55396 KB Output is correct
16 Correct 3 ms 4188 KB Output is correct
17 Correct 9 ms 12892 KB Output is correct
18 Correct 12 ms 17244 KB Output is correct
19 Correct 44 ms 63060 KB Output is correct
20 Correct 34 ms 50948 KB Output is correct
21 Correct 23 ms 33884 KB Output is correct
22 Correct 23 ms 35672 KB Output is correct
23 Correct 15 ms 27228 KB Output is correct
24 Correct 61 ms 82772 KB Output is correct
25 Correct 44 ms 63060 KB Output is correct
26 Correct 52 ms 71612 KB Output is correct
27 Correct 58 ms 79844 KB Output is correct