| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 231111 | MKopchev | 캥거루 (CEOI16_kangaroo) | C++14 | 62 ms | 16792 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int nmax=2e3+42,mod=1e9+7;
int dp[nmax][nmax];
int n,beg,en;
int rec(int to_place,int groups)
{
if(to_place>n)return groups==1;
if(dp[to_place][groups]!=-1)return dp[to_place][groups];
long long ret=0;
if(to_place==beg||to_place==en)
{
ret=rec(to_place+1,groups);//place with the first/last group
ret+=rec(to_place+1,groups+1);//make new group
}
else
{
ret=1LL*(groups-1)*rec(to_place+1,groups-1);//merge 2 groups
int positions=groups+1;
if(to_place>beg)positions--;
if(to_place>en)positions--;
if(positions>0)ret+=1LL*positions*rec(to_place+1,groups+1);//create new group
}
ret=ret%mod;
dp[to_place][groups]=ret;
return ret;
}
int main()
{
scanf("%i%i%i",&n,&beg,&en);
memset(dp,-1,sizeof(dp));
printf("%i\n",rec(1,0));
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
