QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#296498 | #6625. Binaria | HYX1124 | 3 | 1ms | 3884kb | C++14 | 1.9kb | 2024-01-03 08:05:16 | 2024-01-03 08:05:16 |
answer
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#include "lib.h"
#endif
#define rep(i, min, max) for(int i = (min); i <= (max); ++i)
#define nrep(i, max, min) for(int i = (max); i >= (min); --i)
#define reads(str) (scanf("%s", str + 1), strlen(str + 1))
#define case() int Ts = read(); rep(T, 1, Ts)
#define putf(flag) puts((flag) ? "YES" : "NO")
#define put(x) printf("%d ", x)
#define putl(x) printf("%lld ", x)
#define endl() putchar('\n')
using namespace std;
typedef long long ll;
inline int read()
{
int now=0; bool nev=false; char c=getchar();
while(c<'0' || c>'9') { if(c=='-') nev=true; c=getchar(); }
while(c>='0' && c<='9') { now=(now<<1)+(now<<3)+(c&15); c=getchar(); }
return nev?-now:now;
}
const int N = 1e6 + 10;
const ll mod = 106 + 3;
int a[N];
int s[N], pre[N];
ll A[N], nA[N];
ll fpow(ll a, ll k){
ll res = 1;
while(k){
if(k & 1) res = res * a % mod;
a = a * a % mod;
k >>= 1;
}
return res;
}
void init(int n){
A[0] = 1;
rep(i, 1, n) A[i] = A[i - 1] * i % mod;
nA[n] = fpow(A[n], mod - 2);
nrep(i, n, 1) nA[i - 1] = nA[i] * i % mod;
}
inline ll C(int tot, int cur){
return A[tot] * nA[cur] % mod * nA[tot - cur] % mod;
}
int main() {
int n = read(), k = read();
init(n);
rep(i, 1, n - k + 1) s[i] = read();
rep(i, 1, n) a[i] = 2;
rep(i, 1, n - k) {
pre[i] = s[i + 1] - s[i];
a[i + k] = a[i] + pre[i];
if(s[i] == s[i + 1]) continue;
if(a[i] == 2 && pre[i] == 1) a[i] = 0, a[i + k] = 1;
if(a[i] == 2 && pre[i] == -1) a[i] = 1, a[i + k] = 0;
if(a[i + k] != 0 && a[i + k] != 1) puts("0"), exit(0);
}
nrep(i, n - k, 1) a[i] = a[i + k] - pre[i];
// parray(a, n);
int sum = s[1], cnt = 0;
rep(i, 1, k) {
if(a[i] == 2) cnt ++;
else sum -= a[i];
}
// print(sum, cnt);
putl(C(cnt, sum));
}
详细
Subtask #1:
score: 3
Accepted
Test #1:
score: 3
Accepted
time: 1ms
memory: 3852kb
input:
1 1 0
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3532kb
input:
1 1 1
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3548kb
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: 3808kb
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: 1ms
memory: 3592kb
input:
10 3 2 2 2 2 2 2 2 2
output:
3
result:
ok 1 number(s): "3"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
10 3 2 1 1 1 1 2 2 3
output:
1
result:
ok 1 number(s): "1"
Test #7:
score: 0
Accepted
time: 1ms
memory: 3644kb
input:
10 3 1 1 1 0 0 0 0 0
output:
1
result:
ok 1 number(s): "1"
Test #8:
score: 0
Accepted
time: 1ms
memory: 3884kb
input:
10 3 0 0 0 0 0 0 0 0
output:
1
result:
ok 1 number(s): "1"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
10 2 1 1 1 1 1 1 1 1 1
output:
2
result:
ok 1 number(s): "2"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
10 2 1 1 1 1 1 1 1 1 2
output:
1
result:
ok 1 number(s): "1"
Test #11:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
10 2 1 1 0 0 0 0 0 1 2
output:
1
result:
ok 1 number(s): "1"
Test #12:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
2 2 1
output:
2
result:
ok 1 number(s): "2"
Subtask #2:
score: 0
Wrong Answer
Dependency #1:
100%
Accepted
Test #13:
score: 0
Wrong Answer
time: 0ms
memory: 3632kb
input:
10 10 7
output:
11
result:
wrong answer 1st numbers differ - expected: '120', found: '11'
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%