# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
540577 | krit3379 | Tents (JOI18_tents) | C++17 | 278 ms | 70828 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define N 3005
long long dp[N][N],mod=1e9+7;
int main(){
int n,m,i,j;
scanf("%d %d",&n,&m);
for(i=0;i<=n;i++)for(j=0;j<=m;j++){//dp[i][j]: consider placing up until ith row jth col
if(!i||!j)dp[i][j]=1;
else{
dp[i][j]+=dp[i-1][j];//not place in ith row
dp[i][j]+=(j*4*dp[i-1][j-1])%mod;//place 1 in ith row while moving other col
if(j>=2)dp[i][j]+=((j*(j-1)/2)*dp[i-1][j-2])%mod;// place <> choose (i,j1),(i,j2) and move others
if(i>=2)dp[i][j]+=((j*(i-1))*dp[i-2][j-1])%mod;//place up-down choose (i,j1),(i2,j1) and move others
dp[i][j]%=mod;
}
}
printf("%lld",(dp[n][m]-1+mod)%mod);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |