# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
392940 | cpp219 | Tents (JOI18_tents) | C++14 | 421 ms | 71376 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
using namespace std;
typedef pair<ll,ll> LL;
const ll N = 3e3 + 9;
const ll mod = 1e9 + 7;
ll x,y;
ll dp[N][N];
ll f(ll n,ll m){
if (n*m == 0) return m < y;
if (dp[n][m] != -1) return dp[n][m];
ll ans = 0;
if (m >= 2) ans = (ans + f(n - 1,m - 2)*m*(m - 1)/2)%mod;
ans = (ans + 4*m*f(n - 1,m - 1) + f(n - 1,m))%mod;
if (n >= 2) ans = (ans + f(n - 2,m - 1)*m*(n - 1))%mod;
return dp[n][m] = ans;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define task "tst"
if (fopen(task".inp","r")){
freopen(task".inp","r",stdin);
//freopen(task".out","w",stdout);
}
cin>>x>>y; memset(dp,-1,sizeof(dp));
cout<<f(x,y);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |