QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#118526#6625. Binariazhouhuanyi0 2ms4596kbC++111.2kb2023-07-03 16:55:452023-07-03 16:55:48

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 16:55:48]
  • 评测
  • 测评结果:0
  • 用时:2ms
  • 内存:4596kb
  • [2023-07-03 16:55:45]
  • 提交

answer

#include<iostream>
#include<cstdio>
#define N 100000
#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 (s[i]+1==s[i+1]&&i%k!=k-1) used[i%k]=1;
	if (s[i]-1==s[i+1]&&i%k!=k-1) 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: 2ms
memory: 4364kb

input:

1 1
0

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 2ms
memory: 4364kb

input:

1 1
1

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 1ms
memory: 4364kb

input:

10 3
1 2 2 2 2 2 2 2

output:

2

result:

ok 1 number(s): "2"

Test #4:

score: 0
Accepted
time: 2ms
memory: 4360kb

input:

10 3
1 1 0 1 2 3 2 2

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 2ms
memory: 4300kb

input:

10 3
2 2 2 2 2 2 2 2

output:

3

result:

ok 1 number(s): "3"

Test #6:

score: 0
Accepted
time: 2ms
memory: 4596kb

input:

10 3
2 1 1 1 1 2 2 3

output:

1

result:

ok 1 number(s): "1"

Test #7:

score: -3
Wrong Answer
time: 2ms
memory: 4536kb

input:

10 3
1 1 1 0 0 0 0 0

output:

3

result:

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

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%