QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#353857#6625. Binariadeoaihoi0 1ms3680kbC++141.8kb2024-03-14 18:01:322024-03-14 18:01:32

Judging History

你现在查看的是最新测评结果

  • [2024-03-14 18:01:32]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3680kb
  • [2024-03-14 18:01:32]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define int long long

const int NM = 1e6, MOD = 1e6 + 3;

int N, K, a[NM + 5], d[NM + 5];
int mx[NM + 5], mn[NM + 5];
int cnt = 0, ans = 1;

int binpow(int x, int k)
{
    int res = 1;
    while (k > 0)
    {
        if (k & 1)
            res = res * x % MOD;
        k >>= 1;
        x = x * x % MOD;
    }
    return res;
}

int nCk(int n, int k)
{
    if (k < 0 || k > n)
        return 0;
    int res = 1;
    for (int i = n - k + 1; i <= n; i++)
        res = res * i % MOD;
    for (int i = 1; i <= k; i++)
        res = res * binpow(i, MOD - 2) % MOD;
    return res;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> N >> K;
    for (int i = K; i <= N; i++)
        cin >> a[i];
    for (int i = K + 1; i <= N; i++)
    {
        d[i] = a[i] - a[i - 1];
        mx[i % K] = max(mx[i % K], d[i]);
        mn[i % K] = min(mn[i % K], d[i]);
    }
    for (int i = 0; i < K; i++)
    {
        if (mx[i] - mn[i] > 1)
        {
            cout << 0;
            return 0;
        }
    }
    for (int i = 0; i < K; i++)
        if (mn[i] == -1)
        {
            a[K]--;
        }
        else if (mn[i] == mx[i])
            cnt++;
    // for (int i = 1; i <= N; i++)
    // {
    //     cout << a[i] << ' ';
    // }
    // cout << endl;
    // for (int i = 1; i <= N; i++)
    // {
    //     cout << d[i] << ' ';
    // }
    // cout << endl;
    // for (int i = 1; i <= N; i++)
    // {
    //     cout << mx[i] << ' ';
    // }
    // cout << endl;
    // for (int i = 1; i <= N; i++)
    // {
    //     cout << mn[i] << ' ';
    // }
    // cout << endl;
    // cout << cnt;
    cout << nCk(cnt, a[K]);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 3
Accepted
time: 1ms
memory: 3676kb

input:

1 1
0

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 1ms
memory: 3664kb

input:

1 1
1

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

10 3
1 2 2 2 2 2 2 2

output:

2

result:

ok 1 number(s): "2"

Test #4:

score: -3
Wrong Answer
time: 0ms
memory: 3680kb

input:

10 3
1 1 0 1 2 3 2 2

output:

0

result:

wrong answer 1st numbers differ - expected: '1', found: '0'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #5:

0%