//we all are lost trying to be someone
//The best way to predict the future is to create it
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define sz(x) ll(x.size())
#define all(x) x.begin(), x.end()
#define pb push_back
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> tri;
const ll mod=1e6+3;
const ll MAX=1e6;
ll n, k;
ll bin[MAX+20], A[MAX+20], fact[MAX+20];
bool id[MAX+20];
ll mul(ll a, ll b){
return (a*b)%mod;
}
ll binpow(ll base, ll expo){
if(expo==0)return 1;
ll aux=binpow(base, expo/2);
if(expo%2==1){
return mul(mul(aux,aux),base);
}
return mul(aux, aux);
}
ll comb(int a, int b){
return (mul(fact[a],binpow(mul(fact[b],fact[a-b]), mod-2)));
}
void solve(){
cin>>n>>k;
ll aux=-1;
ll pos=0;
ll num=0;
fact[0]=1;
for(int i=1; i<=MAX; i++){
fact[i]=fact[i-1]*i;
fact[i]%=mod;
}
//cout<<3<<' '<<2<<endl;
//cout<<comb(3,2)<<endl;
for(int i=0; i<n-k+1; i++){
cin>>A[i];
if(aux==-1){
aux=A[i];
continue;
}
if(aux!=A[i]){
if(!id[pos%k]){
id[pos%k]=true;
if(A[i]>aux)bin[pos%k]=0;
else bin[pos%k]=1;
}
}
else num++;
aux=A[i];
pos++;
}
//if(num==n-k){
//cout<<"here"<<endl;
// cout<<comb(k,A[0])<<'\n';
// return;
//}
ll sum=0;
ll cant=0;
for(int i=0; i<k; i++){
sum+=bin[i];
if(!id[i])cant++;
//cout<<bin[i]<<' ';
}
//cout<<endl;
//cout<<cant<<' '<<A[0]-sum<<endl;
cout<<comb(cant,A[0]-sum)<<'\n';
}
int main(){
fastio;
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
10588 KB |
Output is correct |
2 |
Correct |
6 ms |
10588 KB |
Output is correct |
3 |
Correct |
6 ms |
12636 KB |
Output is correct |
4 |
Correct |
6 ms |
12760 KB |
Output is correct |
5 |
Correct |
6 ms |
10588 KB |
Output is correct |
6 |
Correct |
6 ms |
12764 KB |
Output is correct |
7 |
Correct |
6 ms |
12632 KB |
Output is correct |
8 |
Correct |
6 ms |
10724 KB |
Output is correct |
9 |
Correct |
6 ms |
10584 KB |
Output is correct |
10 |
Correct |
6 ms |
12632 KB |
Output is correct |
11 |
Correct |
6 ms |
12768 KB |
Output is correct |
12 |
Correct |
6 ms |
10720 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
10588 KB |
Output is correct |
2 |
Correct |
6 ms |
10588 KB |
Output is correct |
3 |
Correct |
6 ms |
12636 KB |
Output is correct |
4 |
Correct |
6 ms |
12760 KB |
Output is correct |
5 |
Correct |
6 ms |
10588 KB |
Output is correct |
6 |
Correct |
6 ms |
12764 KB |
Output is correct |
7 |
Correct |
6 ms |
12632 KB |
Output is correct |
8 |
Correct |
6 ms |
10724 KB |
Output is correct |
9 |
Correct |
6 ms |
10584 KB |
Output is correct |
10 |
Correct |
6 ms |
12632 KB |
Output is correct |
11 |
Correct |
6 ms |
12768 KB |
Output is correct |
12 |
Correct |
6 ms |
10720 KB |
Output is correct |
13 |
Correct |
6 ms |
10588 KB |
Output is correct |
14 |
Correct |
6 ms |
10588 KB |
Output is correct |
15 |
Correct |
6 ms |
12636 KB |
Output is correct |
16 |
Correct |
6 ms |
12632 KB |
Output is correct |
17 |
Correct |
6 ms |
12632 KB |
Output is correct |
18 |
Correct |
6 ms |
12632 KB |
Output is correct |
19 |
Correct |
6 ms |
12636 KB |
Output is correct |
20 |
Correct |
6 ms |
12636 KB |
Output is correct |
21 |
Correct |
6 ms |
12636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
10588 KB |
Output is correct |
2 |
Correct |
6 ms |
10588 KB |
Output is correct |
3 |
Correct |
6 ms |
12636 KB |
Output is correct |
4 |
Correct |
6 ms |
12760 KB |
Output is correct |
5 |
Correct |
6 ms |
10588 KB |
Output is correct |
6 |
Correct |
6 ms |
12764 KB |
Output is correct |
7 |
Correct |
6 ms |
12632 KB |
Output is correct |
8 |
Correct |
6 ms |
10724 KB |
Output is correct |
9 |
Correct |
6 ms |
10584 KB |
Output is correct |
10 |
Correct |
6 ms |
12632 KB |
Output is correct |
11 |
Correct |
6 ms |
12768 KB |
Output is correct |
12 |
Correct |
6 ms |
10720 KB |
Output is correct |
13 |
Correct |
6 ms |
10588 KB |
Output is correct |
14 |
Correct |
6 ms |
10588 KB |
Output is correct |
15 |
Correct |
6 ms |
12636 KB |
Output is correct |
16 |
Correct |
6 ms |
12632 KB |
Output is correct |
17 |
Correct |
6 ms |
12632 KB |
Output is correct |
18 |
Correct |
6 ms |
12632 KB |
Output is correct |
19 |
Correct |
6 ms |
12636 KB |
Output is correct |
20 |
Correct |
6 ms |
12636 KB |
Output is correct |
21 |
Correct |
6 ms |
12636 KB |
Output is correct |
22 |
Correct |
6 ms |
10588 KB |
Output is correct |
23 |
Correct |
6 ms |
12768 KB |
Output is correct |
24 |
Correct |
6 ms |
10588 KB |
Output is correct |
25 |
Correct |
6 ms |
10708 KB |
Output is correct |
26 |
Correct |
6 ms |
10852 KB |
Output is correct |
27 |
Correct |
6 ms |
10588 KB |
Output is correct |
28 |
Correct |
6 ms |
10588 KB |
Output is correct |
29 |
Correct |
6 ms |
12636 KB |
Output is correct |
30 |
Correct |
6 ms |
12756 KB |
Output is correct |
31 |
Correct |
6 ms |
12636 KB |
Output is correct |
32 |
Correct |
6 ms |
12752 KB |
Output is correct |
33 |
Correct |
6 ms |
12636 KB |
Output is correct |
34 |
Correct |
6 ms |
10588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
10588 KB |
Output is correct |
2 |
Correct |
6 ms |
10588 KB |
Output is correct |
3 |
Correct |
6 ms |
12636 KB |
Output is correct |
4 |
Correct |
6 ms |
12760 KB |
Output is correct |
5 |
Correct |
6 ms |
10588 KB |
Output is correct |
6 |
Correct |
6 ms |
12764 KB |
Output is correct |
7 |
Correct |
6 ms |
12632 KB |
Output is correct |
8 |
Correct |
6 ms |
10724 KB |
Output is correct |
9 |
Correct |
6 ms |
10584 KB |
Output is correct |
10 |
Correct |
6 ms |
12632 KB |
Output is correct |
11 |
Correct |
6 ms |
12768 KB |
Output is correct |
12 |
Correct |
6 ms |
10720 KB |
Output is correct |
13 |
Correct |
6 ms |
10588 KB |
Output is correct |
14 |
Correct |
6 ms |
10588 KB |
Output is correct |
15 |
Correct |
6 ms |
12636 KB |
Output is correct |
16 |
Correct |
6 ms |
12632 KB |
Output is correct |
17 |
Correct |
6 ms |
12632 KB |
Output is correct |
18 |
Correct |
6 ms |
12632 KB |
Output is correct |
19 |
Correct |
6 ms |
12636 KB |
Output is correct |
20 |
Correct |
6 ms |
12636 KB |
Output is correct |
21 |
Correct |
6 ms |
12636 KB |
Output is correct |
22 |
Correct |
6 ms |
10588 KB |
Output is correct |
23 |
Correct |
6 ms |
12768 KB |
Output is correct |
24 |
Correct |
6 ms |
10588 KB |
Output is correct |
25 |
Correct |
6 ms |
10708 KB |
Output is correct |
26 |
Correct |
6 ms |
10852 KB |
Output is correct |
27 |
Correct |
6 ms |
10588 KB |
Output is correct |
28 |
Correct |
6 ms |
10588 KB |
Output is correct |
29 |
Correct |
6 ms |
12636 KB |
Output is correct |
30 |
Correct |
6 ms |
12756 KB |
Output is correct |
31 |
Correct |
6 ms |
12636 KB |
Output is correct |
32 |
Correct |
6 ms |
12752 KB |
Output is correct |
33 |
Correct |
6 ms |
12636 KB |
Output is correct |
34 |
Correct |
6 ms |
10588 KB |
Output is correct |
35 |
Correct |
39 ms |
20684 KB |
Output is correct |
36 |
Correct |
41 ms |
21328 KB |
Output is correct |
37 |
Correct |
54 ms |
21588 KB |
Output is correct |
38 |
Correct |
46 ms |
21716 KB |
Output is correct |
39 |
Correct |
36 ms |
20684 KB |
Output is correct |
40 |
Correct |
41 ms |
21588 KB |
Output is correct |
41 |
Correct |
42 ms |
21840 KB |
Output is correct |
42 |
Correct |
38 ms |
20684 KB |
Output is correct |
43 |
Correct |
37 ms |
20816 KB |
Output is correct |
44 |
Correct |
45 ms |
20824 KB |
Output is correct |
45 |
Correct |
41 ms |
20820 KB |
Output is correct |
46 |
Correct |
36 ms |
20816 KB |
Output is correct |
47 |
Correct |
41 ms |
20816 KB |
Output is correct |
48 |
Correct |
41 ms |
21840 KB |
Output is correct |
49 |
Correct |
41 ms |
21840 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
10588 KB |
Output is correct |
2 |
Correct |
6 ms |
10588 KB |
Output is correct |
3 |
Correct |
6 ms |
12636 KB |
Output is correct |
4 |
Correct |
6 ms |
12760 KB |
Output is correct |
5 |
Correct |
6 ms |
10588 KB |
Output is correct |
6 |
Correct |
6 ms |
12764 KB |
Output is correct |
7 |
Correct |
6 ms |
12632 KB |
Output is correct |
8 |
Correct |
6 ms |
10724 KB |
Output is correct |
9 |
Correct |
6 ms |
10584 KB |
Output is correct |
10 |
Correct |
6 ms |
12632 KB |
Output is correct |
11 |
Correct |
6 ms |
12768 KB |
Output is correct |
12 |
Correct |
6 ms |
10720 KB |
Output is correct |
13 |
Correct |
6 ms |
10588 KB |
Output is correct |
14 |
Correct |
6 ms |
10588 KB |
Output is correct |
15 |
Correct |
6 ms |
12636 KB |
Output is correct |
16 |
Correct |
6 ms |
12632 KB |
Output is correct |
17 |
Correct |
6 ms |
12632 KB |
Output is correct |
18 |
Correct |
6 ms |
12632 KB |
Output is correct |
19 |
Correct |
6 ms |
12636 KB |
Output is correct |
20 |
Correct |
6 ms |
12636 KB |
Output is correct |
21 |
Correct |
6 ms |
12636 KB |
Output is correct |
22 |
Correct |
6 ms |
10588 KB |
Output is correct |
23 |
Correct |
6 ms |
12768 KB |
Output is correct |
24 |
Correct |
6 ms |
10588 KB |
Output is correct |
25 |
Correct |
6 ms |
10708 KB |
Output is correct |
26 |
Correct |
6 ms |
10852 KB |
Output is correct |
27 |
Correct |
6 ms |
10588 KB |
Output is correct |
28 |
Correct |
6 ms |
10588 KB |
Output is correct |
29 |
Correct |
6 ms |
12636 KB |
Output is correct |
30 |
Correct |
6 ms |
12756 KB |
Output is correct |
31 |
Correct |
6 ms |
12636 KB |
Output is correct |
32 |
Correct |
6 ms |
12752 KB |
Output is correct |
33 |
Correct |
6 ms |
12636 KB |
Output is correct |
34 |
Correct |
6 ms |
10588 KB |
Output is correct |
35 |
Correct |
39 ms |
20684 KB |
Output is correct |
36 |
Correct |
41 ms |
21328 KB |
Output is correct |
37 |
Correct |
54 ms |
21588 KB |
Output is correct |
38 |
Correct |
46 ms |
21716 KB |
Output is correct |
39 |
Correct |
36 ms |
20684 KB |
Output is correct |
40 |
Correct |
41 ms |
21588 KB |
Output is correct |
41 |
Correct |
42 ms |
21840 KB |
Output is correct |
42 |
Correct |
38 ms |
20684 KB |
Output is correct |
43 |
Correct |
37 ms |
20816 KB |
Output is correct |
44 |
Correct |
45 ms |
20824 KB |
Output is correct |
45 |
Correct |
41 ms |
20820 KB |
Output is correct |
46 |
Correct |
36 ms |
20816 KB |
Output is correct |
47 |
Correct |
41 ms |
20816 KB |
Output is correct |
48 |
Correct |
41 ms |
21840 KB |
Output is correct |
49 |
Correct |
41 ms |
21840 KB |
Output is correct |
50 |
Correct |
50 ms |
23756 KB |
Output is correct |
51 |
Correct |
50 ms |
23636 KB |
Output is correct |
52 |
Correct |
50 ms |
23756 KB |
Output is correct |
53 |
Correct |
53 ms |
23772 KB |
Output is correct |
54 |
Correct |
51 ms |
23768 KB |
Output is correct |
55 |
Correct |
50 ms |
23636 KB |
Output is correct |
56 |
Correct |
50 ms |
23632 KB |
Output is correct |
57 |
Correct |
46 ms |
22608 KB |
Output is correct |
58 |
Correct |
63 ms |
23748 KB |
Output is correct |
59 |
Correct |
50 ms |
23636 KB |
Output is correct |
60 |
Correct |
47 ms |
22620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
10588 KB |
Output is correct |
2 |
Correct |
6 ms |
10588 KB |
Output is correct |
3 |
Correct |
6 ms |
12636 KB |
Output is correct |
4 |
Correct |
6 ms |
12760 KB |
Output is correct |
5 |
Correct |
6 ms |
10588 KB |
Output is correct |
6 |
Correct |
6 ms |
12764 KB |
Output is correct |
7 |
Correct |
6 ms |
12632 KB |
Output is correct |
8 |
Correct |
6 ms |
10724 KB |
Output is correct |
9 |
Correct |
6 ms |
10584 KB |
Output is correct |
10 |
Correct |
6 ms |
12632 KB |
Output is correct |
11 |
Correct |
6 ms |
12768 KB |
Output is correct |
12 |
Correct |
6 ms |
10720 KB |
Output is correct |
13 |
Correct |
6 ms |
10588 KB |
Output is correct |
14 |
Correct |
6 ms |
10588 KB |
Output is correct |
15 |
Correct |
6 ms |
12636 KB |
Output is correct |
16 |
Correct |
6 ms |
12632 KB |
Output is correct |
17 |
Correct |
6 ms |
12632 KB |
Output is correct |
18 |
Correct |
6 ms |
12632 KB |
Output is correct |
19 |
Correct |
6 ms |
12636 KB |
Output is correct |
20 |
Correct |
6 ms |
12636 KB |
Output is correct |
21 |
Correct |
6 ms |
12636 KB |
Output is correct |
22 |
Correct |
6 ms |
10588 KB |
Output is correct |
23 |
Correct |
6 ms |
12768 KB |
Output is correct |
24 |
Correct |
6 ms |
10588 KB |
Output is correct |
25 |
Correct |
6 ms |
10708 KB |
Output is correct |
26 |
Correct |
6 ms |
10852 KB |
Output is correct |
27 |
Correct |
6 ms |
10588 KB |
Output is correct |
28 |
Correct |
6 ms |
10588 KB |
Output is correct |
29 |
Correct |
6 ms |
12636 KB |
Output is correct |
30 |
Correct |
6 ms |
12756 KB |
Output is correct |
31 |
Correct |
6 ms |
12636 KB |
Output is correct |
32 |
Correct |
6 ms |
12752 KB |
Output is correct |
33 |
Correct |
6 ms |
12636 KB |
Output is correct |
34 |
Correct |
6 ms |
10588 KB |
Output is correct |
35 |
Correct |
39 ms |
20684 KB |
Output is correct |
36 |
Correct |
41 ms |
21328 KB |
Output is correct |
37 |
Correct |
54 ms |
21588 KB |
Output is correct |
38 |
Correct |
46 ms |
21716 KB |
Output is correct |
39 |
Correct |
36 ms |
20684 KB |
Output is correct |
40 |
Correct |
41 ms |
21588 KB |
Output is correct |
41 |
Correct |
42 ms |
21840 KB |
Output is correct |
42 |
Correct |
38 ms |
20684 KB |
Output is correct |
43 |
Correct |
37 ms |
20816 KB |
Output is correct |
44 |
Correct |
45 ms |
20824 KB |
Output is correct |
45 |
Correct |
41 ms |
20820 KB |
Output is correct |
46 |
Correct |
36 ms |
20816 KB |
Output is correct |
47 |
Correct |
41 ms |
20816 KB |
Output is correct |
48 |
Correct |
41 ms |
21840 KB |
Output is correct |
49 |
Correct |
41 ms |
21840 KB |
Output is correct |
50 |
Correct |
50 ms |
23756 KB |
Output is correct |
51 |
Correct |
50 ms |
23636 KB |
Output is correct |
52 |
Correct |
50 ms |
23756 KB |
Output is correct |
53 |
Correct |
53 ms |
23772 KB |
Output is correct |
54 |
Correct |
51 ms |
23768 KB |
Output is correct |
55 |
Correct |
50 ms |
23636 KB |
Output is correct |
56 |
Correct |
50 ms |
23632 KB |
Output is correct |
57 |
Correct |
46 ms |
22608 KB |
Output is correct |
58 |
Correct |
63 ms |
23748 KB |
Output is correct |
59 |
Correct |
50 ms |
23636 KB |
Output is correct |
60 |
Correct |
47 ms |
22620 KB |
Output is correct |
61 |
Correct |
7 ms |
10584 KB |
Output is correct |
62 |
Correct |
7 ms |
10716 KB |
Output is correct |
63 |
Correct |
7 ms |
10704 KB |
Output is correct |
64 |
Correct |
7 ms |
12636 KB |
Output is correct |
65 |
Correct |
39 ms |
22280 KB |
Output is correct |
66 |
Correct |
27 ms |
19292 KB |
Output is correct |
67 |
Correct |
51 ms |
24404 KB |
Output is correct |
68 |
Correct |
11 ms |
13148 KB |
Output is correct |
69 |
Correct |
6 ms |
10588 KB |
Output is correct |
70 |
Correct |
7 ms |
10584 KB |
Output is correct |
71 |
Correct |
7 ms |
12636 KB |
Output is correct |