답안 #1033964

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1033964 2024-07-25T08:08:47 Z cowwycow Tents (JOI18_tents) C++14
100 / 100
116 ms 70912 KB
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define name "aaaaaa"
using ll = long long;
using pll = pair<ll, ll>;
using ld = long double;

void file(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(fopen(name".inp", "r")) {
        freopen(name".inp", "r", stdin);
        freopen(name".out", "w", stdout);
    }
}

const int maxn = 3e3 + 5;
const ll mod = 1e9 + 7;

ll dp[maxn][maxn];

void solve (){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < maxn; i++){
		dp[0][i] = 1;
		dp[i][0] = 1;
	}
	for(ll i = 1; i <= n; i++){
		for(ll j = 1; j <= m; j++){
			dp[i][j] += dp[i - 1][j];
			dp[i][j] += dp[i - 1][j - 1] * 4 * j % mod;
			if(j >= 2) dp[i][j] += dp[i - 1][j - 2] * (j * (j - 1) / 2 % mod) % mod;
			if(i >= 2) dp[i][j] += j * (i - 1) % mod * dp[i - 2][j - 1] % mod;
			dp[i][j] %= mod;
		}
	}
	dp[n][m]--;
	if(dp[n][m] < 0) dp[n][m] += mod;
	cout << dp[n][m];
}

int main(){
    file();
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}

Compilation message

tents.cpp: In function 'void file()':
tents.cpp:12:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         freopen(name".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
tents.cpp:13:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         freopen(name".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 26204 KB Output is correct
2 Correct 7 ms 27740 KB Output is correct
3 Correct 5 ms 26168 KB Output is correct
4 Correct 5 ms 26200 KB Output is correct
5 Correct 7 ms 26204 KB Output is correct
6 Correct 5 ms 26200 KB Output is correct
7 Correct 6 ms 27740 KB Output is correct
8 Correct 6 ms 39772 KB Output is correct
9 Correct 6 ms 41304 KB Output is correct
10 Correct 6 ms 39772 KB Output is correct
11 Correct 6 ms 39772 KB Output is correct
12 Correct 7 ms 39772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 26204 KB Output is correct
2 Correct 7 ms 27740 KB Output is correct
3 Correct 5 ms 26168 KB Output is correct
4 Correct 5 ms 26200 KB Output is correct
5 Correct 7 ms 26204 KB Output is correct
6 Correct 5 ms 26200 KB Output is correct
7 Correct 6 ms 27740 KB Output is correct
8 Correct 6 ms 39772 KB Output is correct
9 Correct 6 ms 41304 KB Output is correct
10 Correct 6 ms 39772 KB Output is correct
11 Correct 6 ms 39772 KB Output is correct
12 Correct 7 ms 39772 KB Output is correct
13 Correct 6 ms 31196 KB Output is correct
14 Correct 6 ms 31324 KB Output is correct
15 Correct 62 ms 59096 KB Output is correct
16 Correct 9 ms 33112 KB Output is correct
17 Correct 15 ms 31232 KB Output is correct
18 Correct 20 ms 35420 KB Output is correct
19 Correct 74 ms 64852 KB Output is correct
20 Correct 61 ms 53072 KB Output is correct
21 Correct 39 ms 42184 KB Output is correct
22 Correct 50 ms 45296 KB Output is correct
23 Correct 27 ms 34640 KB Output is correct
24 Correct 90 ms 70912 KB Output is correct
25 Correct 74 ms 63036 KB Output is correct
26 Correct 81 ms 67400 KB Output is correct
27 Correct 116 ms 69280 KB Output is correct