QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#877821 | #6625. Binaria | hhoppitree# | 0 | 1ms | 3840kb | C++17 | 1.1kb | 2025-02-01 09:43:52 | 2025-02-01 09:43:52 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5, P = 1e6 + 3;
int a[N];
int C(int x, int y) {
if (x < 0 || y < 0 || x < y) return 0;
int up = 1, down = 1;
for (int i = 1; i <= y; ++i) {
up = 1ll * up * (x - i + 1) % P;
down = 1ll * down * i % P;
}
auto inv = [&](auto &&self, int a, int b) -> int {
return (a == 1 ? 1 : b - 1ll * self(self, b % a, a) * b / a);
};
return 1ll * up * inv(inv, down, P) % P;
}
signed main() {
int n, m; scanf("%d%d", &n, &m);
for (int i = 1; i <= n - m + 1; ++i) scanf("%d", &a[i]);
int t[4] = {0, 0, 0, 0};
for (int i = 1; i <= m; ++i) {
int o = 3;
long long s1 = 0, s2 = 0;
for (int j = i + 1; j <= n - m + 1; ++j) {
s1 += a[j - 1], s2 += a[j];
if (abs(s1 - s2) >= 2) o = 0;
if (s1 > s2) o &= 2;
if (s1 < s2) o &= 1;
}
if (!o) return 0 & puts("0");
++t[o];
}
printf("%d\n", C(t[3], a[1] - t[2]));
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: 3840kb
input:
1 1 0
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 3
Accepted
time: 0ms
memory: 3840kb
input:
1 1 1
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 3
Accepted
time: 0ms
memory: 3840kb
input:
10 3 1 2 2 2 2 2 2 2
output:
2
result:
ok 1 number(s): "2"
Test #4:
score: 0
Wrong Answer
time: 1ms
memory: 3840kb
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%