QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#736235 | #4893. Imbalance | NineSuns | 10 | 145ms | 199888kb | C++14 | 1.1kb | 2024-11-12 07:59:34 | 2024-11-12 07:59:35 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define pii pair <int, int>
#define fi first
#define se second
#define pb push_back
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int N = 105, mod = 998244353;
int n, k, m, mk[1<<20], f[N][1<<20];
string str;
void solve () {
cin >> n >> k >> m;
if (m) cin >> str;
for (int i = 0;i < (1<<k);i++) mk[i] = __builtin_popcount(i) != (k/2);
int t = 0; for (int i = 0;i < m;i++) t = (t<<1)+(str[i]-'0');
int ans = 0, S = (1<<k)-1;
for (int i = 0;i < (1<<k-m);i++) {
if (mk[(t<<k-m)|i]) {
f[k][(t<<k-m)|i] = 1;
// cout << k << " " << ((t<<k-m)|i) << endl;
}
}
for (int i = k;i < n;i++) {
for (int j = 0;j < (1<<k);j++) {
if (!mk[j]) continue;
(f[i+1][S&(j<<1)] += f[i][j]) %= mod;
(f[i+1][S&(j<<1|1)] += f[i][j]) %= mod;
}
}
for (int i = 0;i < (1<<k);i++) if (mk[i]) (ans += f[n][i]) %= mod;
cout << ans;
}
signed main () {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int T = 1;
while (T--) solve();
return 0;
}
詳細信息
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 1ms
memory: 7616kb
input:
2 2 0
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 10
Accepted
time: 0ms
memory: 7676kb
input:
2 2 1 0
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 10
Accepted
time: 1ms
memory: 7632kb
input:
3 2 0
output:
2
result:
ok 1 number(s): "2"
Test #4:
score: 10
Accepted
time: 2ms
memory: 7632kb
input:
3 2 1 0
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 10
Accepted
time: 1ms
memory: 7820kb
input:
4 2 0
output:
2
result:
ok 1 number(s): "2"
Test #6:
score: 10
Accepted
time: 1ms
memory: 7728kb
input:
4 2 1 0
output:
1
result:
ok 1 number(s): "1"
Test #7:
score: 10
Accepted
time: 0ms
memory: 7688kb
input:
4 4 0
output:
10
result:
ok 1 number(s): "10"
Test #8:
score: 10
Accepted
time: 0ms
memory: 7872kb
input:
4 4 1 1
output:
5
result:
ok 1 number(s): "5"
Test #9:
score: 10
Accepted
time: 1ms
memory: 7660kb
input:
4 4 2 00
output:
3
result:
ok 1 number(s): "3"
Test #10:
score: 10
Accepted
time: 1ms
memory: 7808kb
input:
4 4 3 101
output:
1
result:
ok 1 number(s): "1"
Test #11:
score: 10
Accepted
time: 1ms
memory: 7740kb
input:
5 2 0
output:
2
result:
ok 1 number(s): "2"
Test #12:
score: 10
Accepted
time: 1ms
memory: 7684kb
input:
5 2 1 1
output:
1
result:
ok 1 number(s): "1"
Test #13:
score: 10
Accepted
time: 1ms
memory: 7620kb
input:
5 4 0
output:
14
result:
ok 1 number(s): "14"
Test #14:
score: 10
Accepted
time: 1ms
memory: 7624kb
input:
5 4 1 0
output:
7
result:
ok 1 number(s): "7"
Test #15:
score: 10
Accepted
time: 1ms
memory: 7872kb
input:
5 4 2 01
output:
3
result:
ok 1 number(s): "3"
Test #16:
score: 10
Accepted
time: 1ms
memory: 7628kb
input:
5 4 3 110
output:
1
result:
ok 1 number(s): "1"
Test #17:
score: 10
Accepted
time: 1ms
memory: 7680kb
input:
17 2 0
output:
2
result:
ok 1 number(s): "2"
Test #18:
score: 10
Accepted
time: 1ms
memory: 7792kb
input:
17 2 0
output:
2
result:
ok 1 number(s): "2"
Test #19:
score: 10
Accepted
time: 1ms
memory: 7868kb
input:
17 10 6 110111
output:
621
result:
ok 1 number(s): "621"
Test #20:
score: 10
Accepted
time: 1ms
memory: 7928kb
input:
17 10 2 11
output:
8413
result:
ok 1 number(s): "8413"
Test #21:
score: 10
Accepted
time: 1ms
memory: 7936kb
input:
18 2 1 1
output:
1
result:
ok 1 number(s): "1"
Test #22:
score: 10
Accepted
time: 1ms
memory: 7692kb
input:
18 2 1 1
output:
1
result:
ok 1 number(s): "1"
Test #23:
score: 10
Accepted
time: 1ms
memory: 7664kb
input:
18 8 5 00010
output:
918
result:
ok 1 number(s): "918"
Test #24:
score: 10
Accepted
time: 0ms
memory: 7772kb
input:
18 8 3 001
output:
3404
result:
ok 1 number(s): "3404"
Test #25:
score: 10
Accepted
time: 2ms
memory: 8252kb
input:
18 16 6 100011
output:
2458
result:
ok 1 number(s): "2458"
Test #26:
score: 10
Accepted
time: 0ms
memory: 8336kb
input:
18 16 8 00101101
output:
548
result:
ok 1 number(s): "548"
Test #27:
score: 10
Accepted
time: 0ms
memory: 7676kb
input:
19 2 1 1
output:
1
result:
ok 1 number(s): "1"
Test #28:
score: 10
Accepted
time: 1ms
memory: 7796kb
input:
19 2 0
output:
2
result:
ok 1 number(s): "2"
Test #29:
score: 10
Accepted
time: 1ms
memory: 7768kb
input:
19 6 2 00
output:
3413
result:
ok 1 number(s): "3413"
Test #30:
score: 10
Accepted
time: 1ms
memory: 7724kb
input:
19 6 1 1
output:
7012
result:
ok 1 number(s): "7012"
Test #31:
score: 10
Accepted
time: 0ms
memory: 7752kb
input:
19 12 10 1010110000
output:
266
result:
ok 1 number(s): "266"
Test #32:
score: 10
Accepted
time: 2ms
memory: 7760kb
input:
19 12 3 111
output:
19234
result:
ok 1 number(s): "19234"
Test #33:
score: 10
Accepted
time: 0ms
memory: 8512kb
input:
19 16 2 10
output:
77876
result:
ok 1 number(s): "77876"
Test #34:
score: 10
Accepted
time: 2ms
memory: 8496kb
input:
19 16 0
output:
301208
result:
ok 1 number(s): "301208"
Test #35:
score: 10
Accepted
time: 0ms
memory: 7696kb
input:
20 2 1 0
output:
1
result:
ok 1 number(s): "1"
Test #36:
score: 10
Accepted
time: 1ms
memory: 7696kb
input:
20 2 0
output:
2
result:
ok 1 number(s): "2"
Test #37:
score: 10
Accepted
time: 1ms
memory: 7752kb
input:
20 10 9 110111000
output:
76
result:
ok 1 number(s): "76"
Test #38:
score: 10
Accepted
time: 1ms
memory: 7748kb
input:
20 10 9 110101110
output:
372
result:
ok 1 number(s): "372"
Test #39:
score: 10
Accepted
time: 2ms
memory: 10124kb
input:
20 14 11 10110110000
output:
207
result:
ok 1 number(s): "207"
Test #40:
score: 10
Accepted
time: 0ms
memory: 8092kb
input:
20 14 7 0011011
output:
3675
result:
ok 1 number(s): "3675"
Test #41:
score: 10
Accepted
time: 3ms
memory: 10460kb
input:
20 20 14 10111010000000
output:
58
result:
ok 1 number(s): "58"
Subtask #2:
score: 0
Runtime Error
Dependency #1:
100%
Accepted
Test #42:
score: 0
Runtime Error
input:
114 12 11 11010000010
output:
result:
Subtask #3:
score: 0
Runtime Error
Dependency #1:
100%
Accepted
Test #84:
score: 30
Accepted
time: 145ms
memory: 199888kb
input:
66 20 5 11001
output:
286180948
result:
ok 1 number(s): "286180948"
Test #85:
score: 30
Accepted
time: 115ms
memory: 198368kb
input:
66 20 19 0101001111011100100
output:
334317215
result:
ok 1 number(s): "334317215"
Test #86:
score: 0
Runtime Error
input:
66 22 19 1001101100000100001
output:
result:
Subtask #4:
score: 0
Runtime Error
Test #137:
score: 0
Runtime Error
input:
114 20 0
output:
result:
Subtask #5:
score: 0
Skipped
Dependency #2:
0%