QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#375633#5532. Kangaroosichengzhou6 1ms4032kbC++142.6kb2024-04-03 14:23:452024-04-03 14:23:46

Judging History

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

  • [2024-04-03 14:23:46]
  • 评测
  • 测评结果:6
  • 用时:1ms
  • 内存:4032kb
  • [2024-04-03 14:23:45]
  • 提交

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))%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;
}

详细

Subtask #1:

score: 6
Accepted

Test #1:

score: 6
Accepted
time: 0ms
memory: 3984kb

input:

7 3 6

output:

14

result:

ok 1 number(s): "14"

Subtask #2:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #2:

score: 0
Wrong Answer
time: 1ms
memory: 4032kb

input:

39 36 32

output:

145708195

result:

wrong answer 1st numbers differ - expected: '964903316', found: '145708195'

Subtask #3:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%