제출 #1161978

#제출 시각아이디문제언어결과실행 시간메모리
1161978tminhTents (JOI18_tents)C++20
100 / 100
169 ms71396 KiB
#include "bits/stdc++.h"
using namespace std;

#define ll long long
#define endl '\n'
#define fi first
#define se second
#define vall(a) (a).begin(), (a).end()
#define sze(a) (int)a.size()
#define pii pair<int, int>

#define pb push_back
#define pf push_front


const int mod = 1e9 + 7;
const signed N = 1e6 + 5;
const ll oo = 1e18;

int n, m;
ll dp[3005][3005];
ll f(int r, int c) {
	if (r == 0 || c == 0) return 1;
	ll &res = dp[r][c];


	if (res != -1) return res;
	res = 0;
	
	if (r >= 1 && c >= 2) res = (res + f(r - 1, c - 2) * ((c * (c - 1)) >> 1ll)) % mod;
	if (r >= 2 && c >= 1) res = (res + f(r - 2, c - 1) * (r - 1) * c) % mod;
	if (r >= 1) res = (res + f(r - 1, c)) % mod;
	if (r >= 1 && c >= 1) res = (res + f(r - 1, c - 1) * (c << 2ll)) % mod;
	
	return res % mod;
}
void output() {
	memset(dp, -1, sizeof(dp));
	cout << f(n, m) - 1;
    return;
}

void input() {
	cin >> n >> m;
    output();
    return;
}

signed main () {
    if(fopen("", "r")) {
        freopen("", "r", stdin);
        freopen("", "w", stdout);
    }
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    input();
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

tents.cpp: In function 'int main()':
tents.cpp:51:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |         freopen("", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~
tents.cpp:52:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |         freopen("", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...