이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[3001][3001];
ll mod = 1000000007LL;
ll go(int rows, int cols){
if(rows==0 || cols==0){
return 1LL;
}
if(dp[rows][cols]!=-1){
return dp[rows][cols];
}
ll ret = go(rows-1,cols);
if(cols>=2){
ret += ((ll)cols*(ll)(cols-1))/2LL*go(rows-1,cols-2);
ret %= mod;
}
if(rows>=2){
ret += (ll)cols*(ll)(rows-1)*go(rows-2,cols-1);
ret %= mod;
}
ret += 4LL*(ll)cols*go(rows-1,cols-1);
ret %= mod;
dp[rows][cols] = ret;
return ret;
}
int main(){
for(int a = 0; a<=3000; a++){
for(int b =0; b<=3000; b++){
dp[a][b] = -1;
}
}
int r, c;
cin >> r >> c;
cout << (go(r,c)+mod-1LL)%mod << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |