QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#118988#6625. Binariabatrr#0 17ms19012kbC++232.0kb2023-07-04 17:48:332024-05-31 19:00:35

Judging History

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

  • [2024-05-31 19:00:35]
  • 评测
  • 测评结果:0
  • 用时:17ms
  • 内存:19012kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-04 17:48:33]
  • 提交

answer

#include <bits/stdc++.h>

#define f first
#define s second
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int N = 3000500, inf = 1e9, mod = 1e6 + 3;
const ll INF = 1e18;

int sum(int a, int b) {
    a += b;
    if (a >= mod)
        a -= mod;
    return a;
}

int sub(int a, int b) {
    a -= b;
    if (a < 0)
        a += mod;
    return a;
}

int mult(int a, int b) {
    return 1ll * a * b % mod;
}

int bp(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = mult(res, a);
        a = mult(a, a);
        b >>= 1;
    }
    return res;
}

int inv(int x) {
    return bp(x, mod - 2);
}

int n, k;
int a[N], b[N], f[N];

void no(){
    cout << "0\n";
    exit(0);
}
int C(int k, int n){
    if(0 <= k && k <= n)
        return mult(f[n], inv(mult(f[k], f[n - k])));
    return 0;
}
void solve() {
    f[0] = 1;
    for(int i = 1; i < N; i++)
        f[i] = mult(f[i - 1], i);
    cin >> n >> k;
    for(int i = 0; i < n - k + 1; i++)
        cin >> a[i];
    for(int i = 0; i + 1 < n - k + 1; i++){
        if(a[i] == a[i + 1])
            continue;
        if(abs(a[i] - a[i + 1]) > 1)
            no();
        int x, y;
        if(a[i] < a[i + 1])
            x = 1, y = 2;
        else
            x = 2, y = 1;
        if(b[i] == 0)
            b[i] = x;
        if(b[i + k] == 0)
            b[i + k] = y;
        if(b[i] != x || b[i + k] != y)
            no();
    }
    int x = 0, y = 0;
    for(int i = 0; i < k; i++){
        if(b[i] == 0)
            y++;
        else
            x += b[i] - 1;
    }
    cout << C(a[0] - x, y) << "\n";
}

int main() {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    int t = 1;
//    cin >> t;
    for (int i = 1; i <= t; i++) {
//        cout << "Case #" << i << endl;
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 3
Accepted
time: 17ms
memory: 19012kb

input:

1 1
0

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 12ms
memory: 17404kb

input:

1 1
1

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 17ms
memory: 18732kb

input:

10 3
1 2 2 2 2 2 2 2

output:

2

result:

ok 1 number(s): "2"

Test #4:

score: 0
Accepted
time: 12ms
memory: 17776kb

input:

10 3
1 1 0 1 2 3 2 2

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 12ms
memory: 18392kb

input:

10 3
2 2 2 2 2 2 2 2

output:

3

result:

ok 1 number(s): "3"

Test #6:

score: -3
Wrong Answer
time: 16ms
memory: 17648kb

input:

10 3
2 1 1 1 1 2 2 3

output:

2

result:

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

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%