Submission #986481

# Submission time Handle Problem Language Result Execution time Memory
986481 2024-05-20T15:50:18 Z alexdd Binaria (CCO23_day1problem1) C++17
0 / 25
1 ms 348 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 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[1]-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 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 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 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 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 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 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 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 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 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 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 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -