QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#113718 | #6625. Binaria | 1kri# | 0 | 2ms | 9500kb | C++14 | 995b | 2023-06-19 08:07:58 | 2024-05-31 14:05:44 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <cstring>
#define mod 1000003
using namespace std;
int Qpow(int a,int p){
if (p==0)return 1;
int t=Qpow(a,p/2);
t=1ll*t*t%mod;
if (p&1)t=1ll*t*a%mod;
return t;
}
int n,k,a[1000005];
int c[1000005];
void upd(int x){
if (x>k&&c[x-k]==-1){
c[x-k]=1-c[x];
upd(x-k);
}
if (x<=n-k&&c[x+k]==-1){
c[x+k]=1-c[x];
upd(x+k);
}
return;
}
int C(int n,int m){
if (m<0||m>n)return 0;
int ans=1;
for (int i=n-m+1;i<=n;i++)ans=1ll*ans*i%mod;
int fac=1;
for (int i=1;i<=m;i++)fac=1ll*fac*i%mod;
return 1ll*ans*Qpow(fac,mod-2)%mod;
}
int main(){
cin>>n>>k;
for (int i=1;i<=n-k+1;i++)scanf("%d",&a[i]);
memset(c,-1,sizeof(c));
for (int i=1;i<=n-k;i++){
if (a[i]<a[i+1])c[i]=0,c[i+k]=1;
if (a[i]>a[i+1])c[i]=1,c[i+k]=0;
}
for (int i=1;i<=n;i++)
if (c[i]!=-1)upd(i);
int x=a[1],y=0;
for (int i=1;i<=k;i++){
if (c[i]==1)x--;
if (c[i]==-1)y++;
}
cout<<C(y,x)<<endl;
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 3
Accepted
time: 2ms
memory: 8608kb
input:
1 1 0
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 2ms
memory: 9500kb
input:
1 1 1
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 2ms
memory: 8836kb
input:
10 3 1 2 2 2 2 2 2 2
output:
2
result:
ok 1 number(s): "2"
Test #4:
score: -3
Wrong Answer
time: 0ms
memory: 9060kb
input:
10 3 1 1 0 1 2 3 2 2
output:
0
result:
wrong answer 1st numbers differ - expected: '1', found: '0'
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%