QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#296503 | #6625. Binaria | goodier | 0 | 1ms | 10076kb | C++23 | 1.3kb | 2024-01-03 08:13:12 | 2024-01-03 08:13:12 |
Judging History
answer
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
const int N = 1e6 + 10;
typedef long long ll;
const ll MOD = 1e6 + 3;
ll jc[N], jc_inv[N];
int n, k, a[N], d[N];
ll power(ll a, ll b)
{
ll c = 1;
while(b)
{
if(b & 1) c = c * a % MOD;
a = a * a % MOD;
b >>= 1;
}
return c;
}
ll C(ll n, ll m)
{
if(n < 0 || m < 0 || n < m) return 0;
return jc[n] * jc_inv[n - m] % MOD * jc_inv[m] % MOD;
}
int main()
{
scanf("%d%d", &n, &k);
jc[0] = 1;
for(int i = 1; i <= n; i++) jc[i] = jc[i - 1] * i % MOD;
jc_inv[n] = power(jc[n], MOD - 2);
for(int i = n - 1; i >= 0; i--) jc_inv[i] = jc_inv[i + 1] * (i + 1) % MOD;
for(int i = 0; i < n - k + 1; i++) scanf("%d", &a[i]);
for(int i = 0; i < n - k; i++) d[i] = a[i + 1] - a[i];
int s = a[0], cnt = k;
for(int u = 0; u < k; u++)
{
int flag = 0;
for(int p = u; p < n - k; p += k)
{
if(d[p] < 0)
{
if(d[p] != -1 || flag == -1)
{
puts("0");
return 0;
}
else
{
flag = d[p];
}
}
if(d[p] > 0)
{
if(d[p] != 1 || flag == 1)
{
puts("0");
return 0;
}
else
{
flag = d[p];
}
}
}
if(flag == -1) s--, cnt--;
if(flag == 1) cnt--;
}
printf("%lld\n", C(cnt, s));
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: 10036kb
input:
1 1 0
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 1ms
memory: 10028kb
input:
1 1 1
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 10076kb
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: 1ms
memory: 10004kb
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: 0ms
memory: 10076kb
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: 1ms
memory: 9944kb
input:
10 3 2 1 1 1 1 2 2 3
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%