QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#118554#6625. Binariazhouhuanyi0 12ms15848kbC++111.3kb2023-07-03 17:15:042023-07-03 17:15:06

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-03 17:15:06]
  • 评测
  • 测评结果:0
  • 用时:12ms
  • 内存:15848kb
  • [2023-07-03 17:15:04]
  • 提交

answer

#include<iostream>
#include<cstdio>
#define N 1000000
#define mod 1000003
using namespace std;
int read()
{
    char c=0;
    int sum=0;
    while (c<'0'||c>'9') c=getchar();
    while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
    return sum;
}
int fast_pow(int a,int b)
{
    int res=1,mul=a;
    while (b)
    {
	if (b&1) res=1ll*res*mul%mod;
	mul=1ll*mul*mul%mod,b>>=1;
    }
    return res;
}
int n,k,a[N+1],s[N+1],fac[N+1],invfac[N+1];
bool used[N+1],used2[N+1];
int C(int x,int y)
{
    if (x<y) return 0;
    return 1ll*fac[x]*invfac[y]%mod*invfac[x-y]%mod;
}
int main()
{
    int cnt,cnt2=0;
    fac[0]=1;
    for (int i=1;i<=N;++i) fac[i]=1ll*fac[i-1]*i%mod;
    invfac[N]=fast_pow(fac[N],mod-2);
    for (int i=N-1;i>=0;--i) invfac[i]=1ll*invfac[i+1]*(i+1)%mod;
    n=read(),k=read();
    for (int i=1;i<=n-k+1;++i) a[i]=read(),s[i+k-1]=s[i-1]+a[i];
    for (int i=0;i<=n-1;++i)
    {
	if (i%k!=k-1)
	{
	    if (s[i]+1==s[i+1]) used[i%k]=1;
	    if (s[i]-1==s[i+1]) used2[i%k]=1;
	}
	else
	{
	    if (s[i]+1==s[i+1]-a[n]) used[i%k]=1;
	    if (s[i]-1==s[i+1]-a[n]) used2[i%k]=1;
	}
    }
    cnt=a[1];
    for (int i=0;i<=k-1;++i)
    {
	if (used2[i]) cnt--;
	else if (!used[i]) cnt2++;
    }
    printf("%d\n",C(cnt2,cnt));
    return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 3
Accepted
time: 11ms
memory: 13740kb

input:

1 1
0

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 12ms
memory: 15848kb

input:

1 1
1

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: -3
Wrong Answer
time: 11ms
memory: 15804kb

input:

10 3
1 2 2 2 2 2 2 2

output:

1

result:

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

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #5:

0%