# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
220308 | MKopchev | Tents (JOI18_tents) | C++14 | 222 ms | 35968 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int nmax=3e3+5,mod=1e9+7,fourth=(mod+1)/4;
int dp[nmax][nmax];
int h,w;
int rec(int row,int free)
{
if(row>h)return 1;
if(dp[row][free]!=-1)return dp[row][free];
int ret=rec(row+1,free);//do not place
//place one
//on new and alone
if(free)ret=(ret+4LL*(free)*rec(row+1,free-1))%mod;
//on old(force with some other)
if(free&&row<h)ret=(ret+1LL*free*(h-row)%mod*rec(row+2,free-1))%mod;
//place two
if(free>=2)ret=(ret+1LL*free*(free-1)/2*rec(row+1,free-2))%mod;
dp[row][free]=ret;
return ret;
}
int main()
{
memset(dp,-1,sizeof(dp));
scanf("%i%i",&h,&w);
int output=rec(1,w);
output=(output+mod-1)%mod;
printf("%i\n",output);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |