Submission #986485

# Submission time Handle Problem Language Result Execution time Memory
986485 2024-05-20T15:53:59 Z alexdd Binaria (CCO23_day1problem1) C++17
25 / 25
112 ms 13032 KB
#include<bits/stdc++.h>
#pragma GCC ("fast-math")
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 prod=1;
    for(int i=1;i<=x;i++)
        prod = prod*i%MOD;
    for(int i=1;i<=y;i++)
        prod = prod*put(i,MOD-2)%MOD;
    for(int i=1;i<=x-y;i++)
        prod = prod*put(i,MOD-2)%MOD;
    return prod;
}
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;
}

Compilation message

Main.cpp:2: warning: ignoring '#pragma GCC ' [-Wunknown-pragmas]
    2 | #pragma GCC ("fast-math")
      |
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 344 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 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 344 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 1 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 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 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 1 ms 348 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 344 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 1 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 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 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 1 ms 348 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 62 ms 10120 KB Output is correct
36 Correct 47 ms 10852 KB Output is correct
37 Correct 48 ms 11088 KB Output is correct
38 Correct 64 ms 11152 KB Output is correct
39 Correct 44 ms 9988 KB Output is correct
40 Correct 55 ms 11156 KB Output is correct
41 Correct 48 ms 10976 KB Output is correct
42 Correct 45 ms 10068 KB Output is correct
43 Correct 43 ms 10068 KB Output is correct
44 Correct 40 ms 10156 KB Output is correct
45 Correct 38 ms 9968 KB Output is correct
46 Correct 55 ms 10072 KB Output is correct
47 Correct 60 ms 10216 KB Output is correct
48 Correct 50 ms 11072 KB Output is correct
49 Correct 47 ms 11092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 344 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 1 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 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 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 1 ms 348 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 62 ms 10120 KB Output is correct
36 Correct 47 ms 10852 KB Output is correct
37 Correct 48 ms 11088 KB Output is correct
38 Correct 64 ms 11152 KB Output is correct
39 Correct 44 ms 9988 KB Output is correct
40 Correct 55 ms 11156 KB Output is correct
41 Correct 48 ms 10976 KB Output is correct
42 Correct 45 ms 10068 KB Output is correct
43 Correct 43 ms 10068 KB Output is correct
44 Correct 40 ms 10156 KB Output is correct
45 Correct 38 ms 9968 KB Output is correct
46 Correct 55 ms 10072 KB Output is correct
47 Correct 60 ms 10216 KB Output is correct
48 Correct 50 ms 11072 KB Output is correct
49 Correct 47 ms 11092 KB Output is correct
50 Correct 60 ms 12956 KB Output is correct
51 Correct 75 ms 12888 KB Output is correct
52 Correct 57 ms 12884 KB Output is correct
53 Correct 54 ms 12880 KB Output is correct
54 Correct 57 ms 12924 KB Output is correct
55 Correct 58 ms 13032 KB Output is correct
56 Correct 60 ms 12876 KB Output is correct
57 Correct 51 ms 12116 KB Output is correct
58 Correct 56 ms 12880 KB Output is correct
59 Correct 56 ms 12884 KB Output is correct
60 Correct 52 ms 12116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 344 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 1 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 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 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 1 ms 348 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 62 ms 10120 KB Output is correct
36 Correct 47 ms 10852 KB Output is correct
37 Correct 48 ms 11088 KB Output is correct
38 Correct 64 ms 11152 KB Output is correct
39 Correct 44 ms 9988 KB Output is correct
40 Correct 55 ms 11156 KB Output is correct
41 Correct 48 ms 10976 KB Output is correct
42 Correct 45 ms 10068 KB Output is correct
43 Correct 43 ms 10068 KB Output is correct
44 Correct 40 ms 10156 KB Output is correct
45 Correct 38 ms 9968 KB Output is correct
46 Correct 55 ms 10072 KB Output is correct
47 Correct 60 ms 10216 KB Output is correct
48 Correct 50 ms 11072 KB Output is correct
49 Correct 47 ms 11092 KB Output is correct
50 Correct 60 ms 12956 KB Output is correct
51 Correct 75 ms 12888 KB Output is correct
52 Correct 57 ms 12884 KB Output is correct
53 Correct 54 ms 12880 KB Output is correct
54 Correct 57 ms 12924 KB Output is correct
55 Correct 58 ms 13032 KB Output is correct
56 Correct 60 ms 12876 KB Output is correct
57 Correct 51 ms 12116 KB Output is correct
58 Correct 56 ms 12880 KB Output is correct
59 Correct 56 ms 12884 KB Output is correct
60 Correct 52 ms 12116 KB Output is correct
61 Correct 108 ms 344 KB Output is correct
62 Correct 107 ms 348 KB Output is correct
63 Correct 105 ms 440 KB Output is correct
64 Correct 106 ms 436 KB Output is correct
65 Correct 85 ms 7772 KB Output is correct
66 Correct 87 ms 5484 KB Output is correct
67 Correct 83 ms 12116 KB Output is correct
68 Correct 101 ms 1576 KB Output is correct
69 Correct 112 ms 348 KB Output is correct
70 Correct 108 ms 348 KB Output is correct
71 Correct 110 ms 344 KB Output is correct