QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#326839 | #6625. Binaria | tybbs# | 0 | 2ms | 11876kb | C++14 | 1.1kb | 2024-02-14 08:54:19 | 2024-07-04 03:23:53 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e6+5,mod=1e6+3;
int c[N],a[N],fac[N];
struct DSU{
int fa[N];
void init(int n){
for(int i=1;i<=n;i++){
fa[i]=i;
}
}
int find(int x){
if(x==fa[x]) return x;
return fa[x]=find(fa[x]);
}
void merge(int x,int y){
int fx=find(x),fy=find(y);
fa[fx]=fy;
}
} dsu;
int qpow(int a,int n){
if(n==0) return 1;
int x=qpow(a,n/2);
return (ll)x*x%mod*(n%2?a:1)%mod;
}
int inv(int x){
return qpow(x,mod-2);
}
int main(){
int n,k;cin>>n>>k;
for(int i=1;i<=n-k+1;i++){
cin>>c[i];
}
memset(a,-1,sizeof a);
dsu.init(n);
for(int i=2;i<=n-k+1;i++){
if(c[i]==c[i-1]){
dsu.merge(i-1,i+k-1);
}
if(c[i]>c[i-1]){
a[i-1]=0,a[i+k-1]=1;
}
if(c[i]<c[i-1]){
a[i-1]=1,a[i+k-1]=0;
}
}
for(int i=1;i<=n;i++){
a[dsu.find(i)]=a[i];
}
for(int i=1;i<=n;i++){
a[i]=a[dsu.find(i)];
}
int tot=0,val=c[1];
for(int i=1;i<=k;i++){
if(a[i]==-1) tot++;
if(a[i]==1) val--;
}
fac[0]=1;
for(int i=1;i<=n;i++){
fac[i]=(ll)fac[i-1]*i%mod;
}
cout<<(ll)fac[tot]*inv(fac[val])%mod*inv(fac[tot-val])%mod;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 3
Accepted
time: 0ms
memory: 11820kb
input:
1 1 0
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 2ms
memory: 11876kb
input:
1 1 1
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 11768kb
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: 0ms
memory: 11752kb
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: 0ms
memory: 11752kb
input:
10 3 2 2 2 2 2 2 2 2
output:
3
result:
ok 1 number(s): "3"
Test #6:
score: -3
Wrong Answer
time: 2ms
memory: 11832kb
input:
10 3 2 1 1 1 1 2 2 3
output:
2
result:
wrong answer 1st numbers differ - expected: '1', found: '2'
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%