#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e6+3;
ll rev(ll x){
ll r = 1,p=mod-2;
while(p){
if(p&1) r = r*x%mod;
x=x*x%mod;
p>>=1;
}
return r;
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);
ll n,k;
cin >> n >> k;
vector<ll> a(n-k+1);
for(ll &i : a) cin >> i;
vector<ll> b(n,-1);
for(ll i = 1;i<n-k+1;i++){
if (a[i]<a[i-1]){
b[i-1] = 1;
b[i+k-1] = 0;
}else if (a[i]>a[i-1]){
b[i-1] = 0;
b[i+k-1] = 1;
}else{
}
}
for(ll i = n-1;i>=k;i--){
if (b[i]!=-1&&b[i-k]==-1) b[i-k] = b[i];
}
ll c1= 0,c0=0;
for(ll i = 0;i<k;i++){
c1 += b[i]==1;
c0 += b[i]==0;
}
ll tot = k-c1-c0;
ll w = a[0]-c1;
ll ans = 1;
for(ll i = 1;i<=w;i++){
ans = ans*rev(i)%mod*(tot-i+1)%mod;
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
356 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
356 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
600 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
596 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
356 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
600 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
596 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
600 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
356 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
600 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
596 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
600 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
41 ms |
15956 KB |
Output is correct |
36 |
Correct |
55 ms |
15952 KB |
Output is correct |
37 |
Correct |
43 ms |
15956 KB |
Output is correct |
38 |
Correct |
44 ms |
15956 KB |
Output is correct |
39 |
Correct |
38 ms |
15948 KB |
Output is correct |
40 |
Correct |
45 ms |
15964 KB |
Output is correct |
41 |
Correct |
44 ms |
16104 KB |
Output is correct |
42 |
Correct |
40 ms |
15972 KB |
Output is correct |
43 |
Correct |
42 ms |
15960 KB |
Output is correct |
44 |
Correct |
41 ms |
15952 KB |
Output is correct |
45 |
Correct |
38 ms |
15952 KB |
Output is correct |
46 |
Correct |
39 ms |
16208 KB |
Output is correct |
47 |
Correct |
40 ms |
15956 KB |
Output is correct |
48 |
Correct |
45 ms |
15956 KB |
Output is correct |
49 |
Correct |
42 ms |
15960 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
356 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
600 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
596 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
600 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
41 ms |
15956 KB |
Output is correct |
36 |
Correct |
55 ms |
15952 KB |
Output is correct |
37 |
Correct |
43 ms |
15956 KB |
Output is correct |
38 |
Correct |
44 ms |
15956 KB |
Output is correct |
39 |
Correct |
38 ms |
15948 KB |
Output is correct |
40 |
Correct |
45 ms |
15964 KB |
Output is correct |
41 |
Correct |
44 ms |
16104 KB |
Output is correct |
42 |
Correct |
40 ms |
15972 KB |
Output is correct |
43 |
Correct |
42 ms |
15960 KB |
Output is correct |
44 |
Correct |
41 ms |
15952 KB |
Output is correct |
45 |
Correct |
38 ms |
15952 KB |
Output is correct |
46 |
Correct |
39 ms |
16208 KB |
Output is correct |
47 |
Correct |
40 ms |
15956 KB |
Output is correct |
48 |
Correct |
45 ms |
15956 KB |
Output is correct |
49 |
Correct |
42 ms |
15960 KB |
Output is correct |
50 |
Correct |
60 ms |
15928 KB |
Output is correct |
51 |
Correct |
55 ms |
15944 KB |
Output is correct |
52 |
Correct |
53 ms |
15876 KB |
Output is correct |
53 |
Correct |
57 ms |
15932 KB |
Output is correct |
54 |
Correct |
54 ms |
15952 KB |
Output is correct |
55 |
Correct |
53 ms |
15952 KB |
Output is correct |
56 |
Correct |
53 ms |
15952 KB |
Output is correct |
57 |
Correct |
64 ms |
15936 KB |
Output is correct |
58 |
Correct |
54 ms |
15936 KB |
Output is correct |
59 |
Correct |
65 ms |
15952 KB |
Output is correct |
60 |
Correct |
63 ms |
15948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
356 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
600 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
596 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
600 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
41 ms |
15956 KB |
Output is correct |
36 |
Correct |
55 ms |
15952 KB |
Output is correct |
37 |
Correct |
43 ms |
15956 KB |
Output is correct |
38 |
Correct |
44 ms |
15956 KB |
Output is correct |
39 |
Correct |
38 ms |
15948 KB |
Output is correct |
40 |
Correct |
45 ms |
15964 KB |
Output is correct |
41 |
Correct |
44 ms |
16104 KB |
Output is correct |
42 |
Correct |
40 ms |
15972 KB |
Output is correct |
43 |
Correct |
42 ms |
15960 KB |
Output is correct |
44 |
Correct |
41 ms |
15952 KB |
Output is correct |
45 |
Correct |
38 ms |
15952 KB |
Output is correct |
46 |
Correct |
39 ms |
16208 KB |
Output is correct |
47 |
Correct |
40 ms |
15956 KB |
Output is correct |
48 |
Correct |
45 ms |
15956 KB |
Output is correct |
49 |
Correct |
42 ms |
15960 KB |
Output is correct |
50 |
Correct |
60 ms |
15928 KB |
Output is correct |
51 |
Correct |
55 ms |
15944 KB |
Output is correct |
52 |
Correct |
53 ms |
15876 KB |
Output is correct |
53 |
Correct |
57 ms |
15932 KB |
Output is correct |
54 |
Correct |
54 ms |
15952 KB |
Output is correct |
55 |
Correct |
53 ms |
15952 KB |
Output is correct |
56 |
Correct |
53 ms |
15952 KB |
Output is correct |
57 |
Correct |
64 ms |
15936 KB |
Output is correct |
58 |
Correct |
54 ms |
15936 KB |
Output is correct |
59 |
Correct |
65 ms |
15952 KB |
Output is correct |
60 |
Correct |
63 ms |
15948 KB |
Output is correct |
61 |
Correct |
46 ms |
8284 KB |
Output is correct |
62 |
Correct |
35 ms |
8280 KB |
Output is correct |
63 |
Correct |
78 ms |
8284 KB |
Output is correct |
64 |
Correct |
50 ms |
8280 KB |
Output is correct |
65 |
Correct |
63 ms |
12188 KB |
Output is correct |
66 |
Correct |
47 ms |
10984 KB |
Output is correct |
67 |
Correct |
73 ms |
14420 KB |
Output is correct |
68 |
Correct |
8 ms |
8792 KB |
Output is correct |
69 |
Correct |
90 ms |
8280 KB |
Output is correct |
70 |
Correct |
3 ms |
8280 KB |
Output is correct |
71 |
Correct |
46 ms |
8284 KB |
Output is correct |