Submission #986486

# Submission time Handle Problem Language Result Execution time Memory
986486 2024-05-20T15:55:38 Z alexdd Binaria (CCO23_day1problem1) C++17
25 / 25
61 ms 13136 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1e6+3;
int n,k;
int sum[1000005];
bool verif(int poz, int cur)
{
    if(cur<0 || cur>1) return 0;
    if(poz+k >= n) return 1;
    ///a[poz+k] - a[poz] = sum[poz+1] - sum[poz]
    return verif(poz+k, sum[poz+1] - sum[poz] + cur);
}
int put(int a, int exp)
{
    if(exp==0)
        return 1;
    if(exp%2==0)
        return put(a*a%MOD,exp/2);
    else
        return put(a*a%MOD,exp/2)*a%MOD;
}
int comb(int x, int y)
{
    if(x<y) return 0;
    int aux1=1,aux2=1;
    if(y<=x/2) y = x-y;
    for(int i=y+1;i<=x;i++)
        aux1 = aux1*i%MOD;
    for(int i=1;i<=x-y;i++)
        aux2 = aux2*i%MOD;
    return aux1*put(aux2,MOD-2)%MOD;
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n>>k;
    for(int i=0;i<n-k+1;i++)
        cin>>sum[i];
    int cnt0=0,cnt1=0,cnt01=0;
    for(int i=0;i<k;i++)
    {
        bool pos0 = verif(i,0);
        bool pos1 = verif(i,1);
        if(pos0 && pos1) cnt01++;
        else if(pos0) cnt0++;
        else if(pos1) cnt1++;
        else {cout<<0;return 0;}
    }
    cout<<comb(cnt01,sum[0]-cnt1);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 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 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 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 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 600 KB Output is correct
17 Correct 0 ms 600 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 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 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 600 KB Output is correct
17 Correct 0 ms 600 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 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 344 KB Output is correct
25 Correct 1 ms 460 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 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 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 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 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 600 KB Output is correct
17 Correct 0 ms 600 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 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 344 KB Output is correct
25 Correct 1 ms 460 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 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 42 ms 10064 KB Output is correct
36 Correct 45 ms 10612 KB Output is correct
37 Correct 47 ms 11088 KB Output is correct
38 Correct 46 ms 11092 KB Output is correct
39 Correct 37 ms 10216 KB Output is correct
40 Correct 45 ms 11088 KB Output is correct
41 Correct 46 ms 10996 KB Output is correct
42 Correct 48 ms 10064 KB Output is correct
43 Correct 40 ms 10064 KB Output is correct
44 Correct 39 ms 10084 KB Output is correct
45 Correct 34 ms 10200 KB Output is correct
46 Correct 35 ms 10076 KB Output is correct
47 Correct 38 ms 9980 KB Output is correct
48 Correct 46 ms 10980 KB Output is correct
49 Correct 46 ms 10960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 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 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 600 KB Output is correct
17 Correct 0 ms 600 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 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 344 KB Output is correct
25 Correct 1 ms 460 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 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 42 ms 10064 KB Output is correct
36 Correct 45 ms 10612 KB Output is correct
37 Correct 47 ms 11088 KB Output is correct
38 Correct 46 ms 11092 KB Output is correct
39 Correct 37 ms 10216 KB Output is correct
40 Correct 45 ms 11088 KB Output is correct
41 Correct 46 ms 10996 KB Output is correct
42 Correct 48 ms 10064 KB Output is correct
43 Correct 40 ms 10064 KB Output is correct
44 Correct 39 ms 10084 KB Output is correct
45 Correct 34 ms 10200 KB Output is correct
46 Correct 35 ms 10076 KB Output is correct
47 Correct 38 ms 9980 KB Output is correct
48 Correct 46 ms 10980 KB Output is correct
49 Correct 46 ms 10960 KB Output is correct
50 Correct 61 ms 13136 KB Output is correct
51 Correct 55 ms 13044 KB Output is correct
52 Correct 54 ms 12880 KB Output is correct
53 Correct 56 ms 12884 KB Output is correct
54 Correct 56 ms 12884 KB Output is correct
55 Correct 53 ms 13028 KB Output is correct
56 Correct 54 ms 12884 KB Output is correct
57 Correct 50 ms 12140 KB Output is correct
58 Correct 54 ms 12880 KB Output is correct
59 Correct 53 ms 12884 KB Output is correct
60 Correct 50 ms 12112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 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 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 600 KB Output is correct
17 Correct 0 ms 600 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 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 344 KB Output is correct
25 Correct 1 ms 460 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 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 42 ms 10064 KB Output is correct
36 Correct 45 ms 10612 KB Output is correct
37 Correct 47 ms 11088 KB Output is correct
38 Correct 46 ms 11092 KB Output is correct
39 Correct 37 ms 10216 KB Output is correct
40 Correct 45 ms 11088 KB Output is correct
41 Correct 46 ms 10996 KB Output is correct
42 Correct 48 ms 10064 KB Output is correct
43 Correct 40 ms 10064 KB Output is correct
44 Correct 39 ms 10084 KB Output is correct
45 Correct 34 ms 10200 KB Output is correct
46 Correct 35 ms 10076 KB Output is correct
47 Correct 38 ms 9980 KB Output is correct
48 Correct 46 ms 10980 KB Output is correct
49 Correct 46 ms 10960 KB Output is correct
50 Correct 61 ms 13136 KB Output is correct
51 Correct 55 ms 13044 KB Output is correct
52 Correct 54 ms 12880 KB Output is correct
53 Correct 56 ms 12884 KB Output is correct
54 Correct 56 ms 12884 KB Output is correct
55 Correct 53 ms 13028 KB Output is correct
56 Correct 54 ms 12884 KB Output is correct
57 Correct 50 ms 12140 KB Output is correct
58 Correct 54 ms 12880 KB Output is correct
59 Correct 53 ms 12884 KB Output is correct
60 Correct 50 ms 12112 KB Output is correct
61 Correct 5 ms 348 KB Output is correct
62 Correct 4 ms 348 KB Output is correct
63 Correct 2 ms 344 KB Output is correct
64 Correct 5 ms 348 KB Output is correct
65 Correct 33 ms 8048 KB Output is correct
66 Correct 25 ms 7004 KB Output is correct
67 Correct 51 ms 12140 KB Output is correct
68 Correct 6 ms 2904 KB Output is correct
69 Correct 1 ms 468 KB Output is correct
70 Correct 1 ms 348 KB Output is correct
71 Correct 5 ms 348 KB Output is correct