QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#375643#5532. Kangaroosichengzhou0 0ms3908kbC++142.6kb2024-04-03 14:29:412024-04-03 14:29:41

Judging History

你现在查看的是最新测评结果

  • [2024-04-03 14:29:41]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3908kb
  • [2024-04-03 14:29:41]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=2020,mod=1e9+7;
int n,cs,cf;
LL f[N][N];
int main()
{
    scanf("%d%d%d",&n,&cs,&cf);
    f[0][0]=1;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(i+1==cs)
            {
                if(cf<=i)
                {
                    if(j>=2)
                    {
                        f[i+1][j]+=f[i][j]*(j-1)%mod;
                        f[i+1][j]%=mod;
                    }else if(j==1)
                    {
                        f[i+1][j]+=f[i][j]*j%mod;
                        f[i+1][j]%=mod;
                    }
                }else{
                    if(j>=1)
                    {
                        f[i+1][j]+=f[i][j]*j%mod;
                        f[i+1][j]%=mod;
                    }
                }
            }else if(i+1==cf)
            {
                if(cs<=i)
                {
                    if(j>=2)
                    {
                        f[i+1][j]+=f[i][j]*(j-1)%mod;
                        f[i+1][j]%=mod;
                    }else if(j==1)
                    {
                        f[i+1][j]+=f[i][j]*j%mod;
                        f[i+1][j]%=mod;
                    }
                }else{
                    if(j>=1)
                    {
                        f[i+1][j]+=f[i][j]*j%mod;
                        f[i+1][j]%=mod;
                    }
                }
            }else{
                if(i<cs&&i<cf)
                {
                    if(j>=2)
                    {
                        f[i+1][j-1]+=j*(j-1)%mod*f[i][j]%mod;
                        f[i+1][j-1]%=mod;
                    }
                }else if(cs<=i&&cf<=i)
                {
                    if(j>=2)
                    {
                        f[i+1][j-1]+=((j-1)*(j-1)-(j-2)-1)%mod*f[i][j]%mod;
                        f[i+1][j-1]%=mod;
                    }
                }else if(cs<=i)
                {
                    if(j>=2)
                    {
                        f[i+1][j-1]+=(j*(j-1)-(j-1))%mod*f[i][j]%mod;
                        f[i+1][j-1]%=mod;
                    }
                }else{
                    if(j>=2)
                    {
                        f[i+1][j-1]+=(j*(j-1)-(j-1))%mod*f[i][j]%mod;
                        f[i+1][j-1]%=mod;
                    }
                }
            }
            f[i+1][j+1]+=f[i][j];
            f[i+1][j+1]%=mod;
        }
    }
    printf("%lld\n",f[n][1]);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3908kb

input:

7 3 6

output:

0

result:

wrong answer 1st numbers differ - expected: '14', found: '0'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%