QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#797922#9647. 数位 DPXiaohuba40 614ms6316kbC++233.9kb2024-12-03 21:07:552024-12-03 21:07:56

Judging History

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

  • [2024-12-03 21:07:56]
  • 评测
  • 测评结果:40
  • 用时:614ms
  • 内存:6316kb
  • [2024-12-03 21:07:55]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

// #define LOCK_GETCHAR
// #define USE_INT_128

#if __cplusplus < 201400
#warning "Please use c++14 or higher."
#define CONSTEXPR_FUNC
#define ENABLE_IF_INT
#else
#define CONSTEXPR_FUNC constexpr
#define ENABLE_IF_INT , enable_if_t<_is_integer<T>, int> = 0
template <class T> constexpr bool _is_integer = numeric_limits<T>::is_integer;
template <> constexpr bool _is_integer<bool> = false;
template <> constexpr bool _is_integer<char> = false;
#ifdef USE_INT_128
template <> constexpr bool _is_integer<__int128> = true;
template <> constexpr bool _is_integer<__uint128_t> = true;
#endif
#endif

#if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(LOCK_GETCHAR)
#define getchar getchar_unlocked
#endif

#define il inline
#define mkp make_pair
#define fi first
#define se second
#define ssz(x) (signed((x).size()))
#define _loop_i_t(j, k) make_signed_t<decltype((j) - (k))>
#define For(i, j, k) for (_loop_i_t(j, k) i = (j); i <= (k); ++i) // NOLINT
#define ForDown(i, j, k)                                                       \
  for (_loop_i_t(j, k) i = (j); i >= decltype(i)(k); --i) // NOLINT
#define eb emplace_back
#ifndef ONLINE_JUDGE
#define FileIO(filename)                                                       \
  freopen(filename ".in", "r", stdin);                                         \
  freopen(filename ".out", "w", stdout)
#else
#define FileIO(filename) void(0)
#endif

using ll = long long;
using uint = unsigned int;
using ull = unsigned long long;
using db = double;
using ldb = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#ifdef USE_INT_128
using lll = __int128_t;
using ulll = __uint128_t;
#endif

// clang-format off
CONSTEXPR_FUNC il ll qpow(ll x, ull y, ll mod){ ll ans = 1; x %= mod; while (y) { if (y & 1) (ans *= x) %= mod; (x *= x) %= mod; y >>= 1; } return ans; }
template<typename T> CONSTEXPR_FUNC il void cmin(T & x, const T &y){ x = min(x, y); }
template<typename T> CONSTEXPR_FUNC il void cmax(T & x, const T &y){ x = max(x, y); }
template<typename T ENABLE_IF_INT> il void read(T &x){ x = 0; int f = 1; int c = getchar(); while (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); } while (isdigit(c)) { x = x * 10 + (c - '0'); c = getchar(); } x *= f; }
template<typename T, typename ... Args> il void read(T &x, Args &... y){ read(x), read(y...); }
// clang-format on

// File head end

namespace {
constexpr int MAXN = 4e5 + 5;
int n, m, k, q;
uint f[2][1 << 16], tmp[1 << 16], pw[MAXN], sum[1 << 16];
string s;
void Main() {
  FileIO("dp");
  pw[0] = 1;
  For(i, 1, MAXN - 1) pw[i] = pw[i - 1] << 1;
  cin >> n >> k >> q >> s;
  For(i, 0, (1 << k) - 1) f[1][i] = 1;
  For(i, 2, n) {
    int cur = i & 1, pre = cur ^ 1;
    memset(f[cur], 0, sizeof f[cur]);
    if (s[i - 2] == 'A') {
      uint sum = 0;
      ForDown(S, (1 << k) - 1, 0) {
        sum += f[pre][S];
        f[cur][S] = sum + f[pre][S] * ((1 << k) - S - 1);
      }
    } else {
      For(j, 0, k - 1) {
        memset(tmp, 0, sizeof tmp);
        For(S, 0, (1 << k) - 1) tmp[S >> (j + 1)] +=
            (S >> j & 1) ? f[pre][S] : 0;
        For(o, 0, (k - j - 1) - 1)
            For(S, 0, (1 << (k - j - 1)) - 1) if (S >> o & 1) tmp[S] +=
            tmp[S ^ 1 << o];
        For(S, 0, (1 << (k - j - 1)) - 1)
            f[cur][S << (j + 1) | ((1 << (j + 1)) - 1)] += tmp[S] * pw[j];
      }
      memcpy(tmp, f[pre], sizeof f[pre]);
      For(o, 0, k - 1) For(S, 0, (1 << k) - 1) if (S >> o & 1) tmp[S] +=
          tmp[S ^ 1 << o];
      For(S, 0, (1 << k) - 1) f[cur][S] += tmp[S];
    }
    // For(j, 0, (1 << k) - 1) cerr << i << ' ' << j << ' ' << f[cur][j] <<
    // '\n';
  }
  sum[(1 << k) - 1] = f[n & 1][(1 << k) - 1];
  ForDown(i, (1 << k) - 2, 0) sum[i] = f[n & 1][i] + sum[i + 1];
  while (q--) {
    cin >> m;
    cout << sum[m] << '\n';
  }
}
} // namespace

signed main() { return Main(), 0; }

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 2ms
memory: 5676kb

input:

4 5 200
AAA
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

output:

1
16
81
256
625
1296
2401
4096
6561
10000
14641
20736
28561
38416
50625
65536
83521
104976
130321
160000
194481
234256
279841
331776
390625
456976
531441
614656
707281
810000
923521
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
104857...

result:

ok 200 lines

Test #2:

score: 10
Accepted
time: 2ms
memory: 5976kb

input:

4 5 200
XXX
15
29
23
29
23
15
30
27
27
23
30
29
27
23
30
23
27
23
30
30
30
30
15
29
27
23
15
30
15
27
27
23
15
30
29
27
23
23
15
23
27
27
27
29
23
30
29
30
27
27
30
27
27
15
27
15
23
23
27
15
23
30
30
29
30
15
30
15
29
15
27
29
15
29
30
30
15
29
15
27
27
15
27
27
30
27
30
30
15
30
29
27
30
23
27
27
...

output:

1043136
962496
981696
962496
981696
1043136
961536
966336
966336
981696
961536
962496
966336
981696
961536
981696
966336
981696
961536
961536
961536
961536
1043136
962496
966336
981696
1043136
961536
1043136
966336
966336
981696
1043136
961536
962496
966336
981696
981696
1043136
981696
966336
966336...

result:

ok 200 lines

Test #3:

score: 10
Accepted
time: 0ms
memory: 6052kb

input:

4 5 200
AXA
18
10
11
16
27
4
15
15
9
17
29
18
30
9
24
20
20
6
31
1
11
2
7
9
29
6
26
12
28
18
20
0
12
10
25
11
6
31
30
26
27
20
17
3
24
0
8
23
7
3
14
5
15
24
22
6
21
5
27
6
10
19
16
15
0
28
29
23
9
15
28
14
19
26
30
24
6
2
9
22
23
20
13
12
18
15
25
10
17
2
5
11
4
13
26
13
6
22
25
15
23
25
30
19
10
17...

output:

281568
632544
599340
327680
72280
890624
447576
447576
668702
305790
38328
281568
23936
668702
122880
228864
228864
814944
11440
1013855
599340
975600
777900
668702
38328
814944
88512
550400
52224
281568
228864
1048576
550400
632544
106428
599340
814944
11440
23936
88512
72280
228864
305790
939542
1...

result:

ok 200 lines

Test #4:

score: 10
Accepted
time: 1ms
memory: 5672kb

input:

4 5 200
AAA
2
1
6
16
0
20
5
25
24
27
10
5
25
14
2
3
18
11
5
27
23
21
19
7
25
20
25
15
29
20
5
11
25
1
19
6
13
18
31
30
17
14
10
12
16
18
29
27
24
2
23
24
26
14
18
29
6
9
21
0
18
27
10
12
6
0
20
6
29
25
18
18
27
6
29
10
23
19
24
15
6
22
11
9
5
25
19
9
14
0
22
30
3
13
19
13
15
10
5
21
14
21
27
3
31
25...

output:

810000
923521
456976
65536
1048576
20736
531441
2401
4096
625
234256
531441
2401
104976
810000
707281
38416
194481
531441
625
6561
14641
28561
390625
2401
20736
2401
83521
81
20736
531441
194481
2401
923521
28561
456976
130321
38416
1
16
50625
104976
234256
160000
65536
38416
81
625
4096
810000
6561...

result:

ok 200 lines

Test #5:

score: 10
Accepted
time: 1ms
memory: 6164kb

input:

4 5 200
OOX
9
13
15
3
12
7
25
14
30
31
10
10
5
29
28
2
31
16
24
9
9
16
25
7
7
22
3
17
29
10
30
19
27
20
3
24
5
11
23
17
30
14
31
19
20
11
4
15
23
2
26
26
13
25
12
15
28
22
25
13
28
13
4
19
8
14
19
17
21
21
5
6
19
23
16
28
4
16
31
22
11
28
22
5
31
30
24
11
30
25
10
28
4
23
28
0
6
10
28
10
17
22
26
5
...

output:

1044476
1043440
1043136
1048556
1043456
1048240
966640
1043200
961536
961280
1044416
1044416
1048316
962496
962560
1048560
961280
983040
966656
1044476
1044476
983040
966640
1048240
1048240
981760
1048556
983036
962496
1044416
961536
982960
966336
982016
1048556
966656
1048316
1044400
981696
983036
...

result:

ok 200 lines

Test #6:

score: 10
Accepted
time: 0ms
memory: 5736kb

input:

4 5 200
AAA
10
22
27
29
26
14
19
23
7
30
19
9
20
25
15
2
30
2
27
25
19
5
28
23
10
20
26
15
13
8
0
13
31
17
22
0
31
9
30
27
31
13
29
11
23
26
12
9
21
22
3
6
27
18
25
28
25
6
27
21
0
27
13
19
31
29
11
14
11
9
10
18
13
26
22
3
17
11
7
29
23
26
6
17
11
27
30
18
18
12
8
29
14
4
2
22
31
13
19
20
24
23
6
3...

output:

234256
10000
625
81
1296
104976
28561
6561
390625
16
28561
279841
20736
2401
83521
810000
16
810000
625
2401
28561
531441
256
6561
234256
20736
1296
83521
130321
331776
1048576
130321
1
50625
10000
1048576
1
279841
16
625
1
130321
81
194481
6561
1296
160000
279841
14641
10000
707281
456976
625
38416...

result:

ok 200 lines

Test #7:

score: 10
Accepted
time: 0ms
memory: 5684kb

input:

4 5 200
AAA
21
18
31
9
21
8
4
11
25
24
26
18
29
18
15
27
16
27
13
18
21
22
27
11
31
17
12
26
14
12
4
1
13
19
27
2
24
6
9
5
19
22
31
30
7
24
22
11
20
9
29
21
13
23
9
14
30
24
30
26
3
20
25
31
3
17
2
15
6
29
12
12
26
25
1
25
4
13
15
25
5
28
22
14
12
5
9
10
26
27
19
27
28
14
4
22
8
20
17
22
30
29
17
31...

output:

14641
38416
1
279841
14641
331776
614656
194481
2401
4096
1296
38416
81
38416
83521
625
65536
625
130321
38416
14641
10000
625
194481
1
50625
160000
1296
104976
160000
614656
923521
130321
28561
625
810000
4096
456976
279841
531441
28561
10000
1
16
390625
4096
10000
194481
20736
279841
81
14641
1303...

result:

ok 200 lines

Test #8:

score: 10
Accepted
time: 2ms
memory: 5924kb

input:

4 5 200
OXX
29
17
13
0
4
0
0
15
14
21
18
9
13
27
16
27
29
30
4
31
3
23
31
9
23
20
9
29
28
1
26
7
26
21
17
27
18
25
23
14
13
14
30
6
25
24
15
28
0
6
14
10
7
13
26
22
9
5
20
15
21
23
20
22
9
27
18
6
17
3
26
31
12
20
26
6
19
17
5
13
26
31
18
30
18
30
20
31
27
18
29
29
2
31
28
6
0
7
6
22
18
28
9
13
12
2...

output:

962496
983036
1043440
1048576
1048320
1048576
1048576
1043136
1043200
982000
982976
1044476
1043440
966336
983040
966336
962496
961536
1048320
961280
1048556
981696
961280
1044476
981696
982016
1044476
962496
962560
1048575
966400
1048240
966400
982000
983036
966336
982976
966640
981696
1043200
1043...

result:

ok 200 lines

Test #9:

score: 10
Accepted
time: 1ms
memory: 5976kb

input:

4 5 200
XAA
30
14
15
21
5
17
14
25
14
20
20
9
11
10
11
1
5
4
9
17
24
29
26
5
20
12
30
3
14
31
31
5
22
23
3
2
28
12
26
23
9
18
20
26
25
3
16
26
2
23
24
1
12
9
18
25
19
20
19
3
12
11
4
20
25
5
22
14
15
22
11
7
23
5
10
24
18
0
9
10
23
19
22
15
26
30
26
20
12
19
25
6
23
24
11
19
18
31
29
28
18
18
26
5
2...

output:

2176
295488
261256
88572
733374
172350
295488
31164
295488
105984
105984
506782
418068
460768
418068
983103
733374
790272
506782
172350
40960
5112
22464
733374
105984
371200
2176
856138
295488
528
528
733374
72000
57672
856138
918000
9216
371200
22464
57672
506782
148960
105984
22464
31164
856138
19...

result:

ok 200 lines

Test #10:

score: 10
Accepted
time: 2ms
memory: 5940kb

input:

4 5 200
XXO
0
14
16
6
13
0
28
22
13
3
19
17
30
24
8
21
6
16
1
11
10
17
6
13
13
3
17
7
7
22
6
12
19
16
2
15
25
17
23
5
21
29
18
14
23
0
28
7
6
24
25
9
28
9
17
14
28
20
15
29
17
27
19
9
14
25
3
24
12
25
10
25
30
19
3
13
9
2
15
18
3
30
10
5
21
22
28
10
15
13
15
25
19
19
8
7
16
29
7
25
10
29
30
18
22
18...

output:

1048576
1043200
983040
1048256
1043440
1048576
962560
981760
1043440
1048556
982960
983036
961536
966656
1044480
982000
1048256
983040
1048575
1044400
1044416
983036
1048256
1043440
1043440
1048556
983036
1048240
1048240
981760
1048256
1043456
982960
983040
1048560
1043136
966640
983036
981696
10483...

result:

ok 200 lines

Subtask #2:

score: 10
Accepted

Test #11:

score: 10
Accepted
time: 0ms
memory: 5768kb

input:

20 8 20
AAAAAAAAAAAAAAAAAAA
255
254
253
252
251
250
249
248
247
246
245
244
243
242
241
240
239
238
237
236

output:

1
1048576
3486784401
0
1977800241
3104833536
3095271137
0
689956897
1661992960
1226119153
0
4176394193
1846542336
2980478145
0
1144323905
2182086656
2763774801
0

result:

ok 20 lines

Test #12:

score: 10
Accepted
time: 2ms
memory: 6000kb

input:

20 8 20
XXOOXXXOOOXOOXXXXXX
223
254
239
127
251
247
223
223
254
253
254
239
247
223
127
223
251
127
251
254

output:

3157225472
0
3157225472
3157225472
3157225472
3157225472
3157225472
3157225472
0
4230967296
0
3157225472
3157225472
3157225472
3157225472
3157225472
3157225472
3157225472
3157225472
0

result:

ok 20 lines

Test #13:

score: 10
Accepted
time: 2ms
memory: 5992kb

input:

20 8 20
AOAOAXAOAXAOAXAOAXA
1
139
141
253
49
89
100
235
106
169
177
199
27
63
169
104
191
54
239
54

output:

2596932351
444889112
642944536
3394047424
1995656860
1794163992
0
3083125088
3783262208
1396280088
2829574680
3125900656
2757493016
2952862816
1396280088
0
2713869248
3514826752
498553792
3514826752

result:

ok 20 lines

Test #14:

score: 10
Accepted
time: 1ms
memory: 6000kb

input:

20 8 20
AAAAAAXAAAAAAOAAAAA
182
64
25
84
227
184
255
183
201
39
43
232
217
63
4
94
85
164
120
175

output:

2580545536
0
841269017
0
4233876109
0
3196053143
4234287951
722457003
1479575031
4073032191
0
2835298401
89573919
0
1297088512
3057585635
0
0
2640696959

result:

ok 20 lines

Test #15:

score: 10
Accepted
time: 2ms
memory: 6044kb

input:

20 8 20
XXOOOXAOOXXOOAOXOXX
13
144
231
225
195
11
210
171
187
111
220
55
239
205
221
33
233
7
247
183

output:

1914607548
0
2820613408
4190143288
1349955368
4104752340
3682598912
763900496
850003872
344774176
0
3575735056
907161152
379632112
998910688
4293952878
1178842864
3866438084
3842625600
1048790816

result:

ok 20 lines

Test #16:

score: 10
Accepted
time: 0ms
memory: 5984kb

input:

20 8 20
AOXAXAAOAAXAAOAXOXX
40
187
158
14
49
213
39
29
254
181
46
220
231
142
40
90
206
88
36
191

output:

0
3193371575
835715072
4182769664
3263242009
3866789033
3429976231
1248772075
491782144
2441390825
946864128
0
2632295535
1047527424
0
3635412992
449839104
0
0
2726809173

result:

ok 20 lines

Test #17:

score: 10
Accepted
time: 0ms
memory: 6008kb

input:

20 8 20
AAAAAAAAAAAAAAAAOAX
141
207
65
228
151
65
57
252
94
252
199
62
47
228
194
151
255
55
238
61

output:

680445295
2794147121
2672008899
0
1498887811
2672008899
1254672067
0
565182464
0
715997235
3635412992
1301139995
0
110100480
1498887811
876053577
19247395
579862528
586255357

result:

ok 20 lines

Test #18:

score: 10
Accepted
time: 0ms
memory: 5984kb

input:

20 8 20
OXOAXXXAXOOAAOOAOOX
202
90
82
55
206
140
9
217
117
142
157
157
110
206
36
44
83
49
19
235

output:

1857028096
3828350976
1183842304
201104635
1857028096
0
1421874471
2356948025
3339221653
1884291072
142114461
142114461
397410304
1857028096
0
0
4020004345
3097298385
4204969527
550445409

result:

ok 20 lines

Test #19:

score: 10
Accepted
time: 1ms
memory: 5720kb

input:

20 8 20
AAAAAAAAAAAAAAAAAAA
117
85
62
163
251
104
153
178
187
114
155
237
75
61
231
30
69
9
222
106

output:

1504122353
46640497
4161798144
3797657873
1977800241
0
3554417505
2249195520
1941563185
2651848704
3039303601
2763774801
2490579697
4287090833
2881090913
1812987904
1915233073
611513377
4094689280
1863319552

result:

ok 20 lines

Test #20:

score: 10
Accepted
time: 2ms
memory: 5980kb

input:

20 8 20
XOXXXXXXOOOXAXOXXXX
41
169
154
217
104
167
76
158
178
90
201
227
187
90
26
239
5
34
183
210

output:

4294885121
4294006675
1752170496
4280995513
0
3331336011
0
1244659712
674234368
3195011072
4294156851
2856438223
1008201685
3195011072
2278555648
3165363643
67104071
1982857216
3855648865
2100297728

result:

ok 20 lines

Subtask #3:

score: 10
Accepted

Test #21:

score: 10
Accepted
time: 11ms
memory: 6040kb

input:

200 16 1
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
65535

output:

1

result:

ok single line: '1'

Test #22:

score: 10
Accepted
time: 605ms
memory: 6236kb

input:

200 16 1
OXOXXXOXXOXOXXOOOXXXXOOXXOOOXOOXOOXXOOOOXXOXOOXOXXXOXXXXXXXOXOXOOXOXXOOOXOOXXOOOXXXXOXXXOOXXOXOXOXXOOOOOOOOOOXXOXXXOXXOOOXOOXXXOOXXOXXOOOXOOOXOOOXOXXXXXOXOOOXXXXOXXXOOOOOOOXOOXOXXXXXOXOXOXOOXXXOXXOXX
63487

output:

0

result:

ok single line: '0'

Test #23:

score: 10
Accepted
time: 310ms
memory: 6232kb

input:

200 16 1
AXAXAXAOAOAXAXAOAOAXAXAOAOAOAXAOAOAOAXAOAOAOAOAXAXAOAOAXAOAOAOAXAOAXAXAOAOAOAXAOAXAOAXAOAOAOAOAXAXAXAXAXAXAOAXAOAOAOAOAXAXAOAXAXAOAXAXAOAXAOAOAXAOAOAXAXAOAXAOAXAOAOAOAOAOAOAOAOAXAXAOAOAOAOAOAOAXAOAOA
4359

output:

2017260928

result:

ok single line: '2017260928'

Test #24:

score: 10
Accepted
time: 96ms
memory: 6184kb

input:

200 16 1
AAAAAAOAAAAAAOAAAAAAXAAAAAAOAAAAAAXAAAAAAXAAAAAAXAAAAAAXAAAAAAOAAAAAAXAAAAAAXAAAAAAXAAAAAAOAAAAAAXAAAAAAOAAAAAAXAAAAAAOAAAAAAOAAAAAAOAAAAAAXAAAAAAOAAAAAAXAAAAAAOAAAAAAOAAAAAAOAAAAAAXAAAAAAXAAAAAAOAAA
8276

output:

0

result:

ok single line: '0'

Test #25:

score: 10
Accepted
time: 526ms
memory: 6236kb

input:

200 16 1
OOOOXOAOXXXOOAXXOOXOAXOXOXXAOOXXOXAXXXOOOAXOXOXOAOXXXOOAXXOOXXAOXOXOXAOXXOXXAOOOXOOAXOOXOOAOOOXXXAOXOOXOAOOOOOXAXOOOXOAXOXOOOAOXXOXXAOOOXOXAOOOOOOAOXXXOOAOOOOXXAOXOOXOAXXOXXXAXXXXOOAOOXXXXAOOXOOXAOOX
62733

output:

118423552

result:

ok single line: '118423552'

Test #26:

score: 10
Accepted
time: 280ms
memory: 6180kb

input:

200 16 1
XAXXAAOAOAOXOXAAAXAAXAAAXOAXAAXOXOAOAXOOAAAAAXAAOXAAAOOAOAAXAXXXOAOOOOXAAXAAAOAXOAAAXAAAAAAXOAAAAXAAOAAAAAOAAXOAOOXXAOAXOOAAAAOAAAAAAAAXXAAOAOOXAOAOAAAAAAAXAAXOAAOOAAXAAAXAAOAAXAXOXAXXXXOXXAOAAOAOAAA
36975

output:

3800841600

result:

ok single line: '3800841600'

Test #27:

score: 10
Accepted
time: 100ms
memory: 6236kb

input:

200 16 1
XAAXAXAAAAAXXAOAAOXAAAAXAAAAAAAAAAXOAAAAAAAXAAAAAAAOAAAAAOAAAAAAAAAOAAAAAOAAAAAAAAAAAAAAAAAAAAXAAAOOXAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAXAAOAAAAAAAAAAAAAAAOAAAAAXAAAAAAAAAAAAAAAAAAAAAAAXOAXAAAAAXAAAAAA
42961

output:

4143734528

result:

ok single line: '4143734528'

Test #28:

score: 10
Accepted
time: 535ms
memory: 6236kb

input:

200 16 1
XOOOXXXXOXXAOXXAOOXXOXAOXOOAOOOOAAXOAXOXXAOOOXXOOXOXOOXOXOXXXAOXOXOXOXXXAXOAOXXXOOOXXXXXOOOOOOXAOXXXAXOXXAOOOXXAOXOOXOOXOXXOXOXOOAOXOOAXAXXOXAOXXXXOOXAOXXOOXXOXAOOOOAXXAOOOXXOOXOOOXAOXXOXOAOXOXAOXOXX
32762

output:

0

result:

ok single line: '0'

Test #29:

score: 10
Accepted
time: 42ms
memory: 6240kb

input:

200 16 1
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAXOAAAXAAXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAXAAAAAAAAAAAAAAAAAAAOAAAAOAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAOAAAAAAAAAAAAAAAA
55979

output:

347602944

result:

ok single line: '347602944'

Test #30:

score: 10
Accepted
time: 555ms
memory: 6288kb

input:

200 16 1
AXXOOOOXOOOOOXOXOAXOOXOXOXAOXOOXXXOXOAOOAOOAOXOAOXXXXOXAAOXOOXXXXAOOOXOXOXXOAOXXOXOXXXXXOOXAXOOXOOOOOOXXXXOOXOOOOOXOXOOXXOOXOXXXXOOOAXXOXOAOOXXOOXAOXXOXOXOXXXOOAXOXXAXOOAXXXOXAOOOXXOOOAOOOXOAXOXOXOXO
30929

output:

3913125083

result:

ok single line: '3913125083'

Subtask #4:

score: 10
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #31:

score: 10
Accepted
time: 8ms
memory: 5924kb

input:

200 16 200
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
65535
65534
65533
65532
65531
65530
65529
65528
65527
65526
65525
65524
65523
65522
65521...

output:

1
0
2868424865
0
1018802913
0
816568513
0
2244855105
0
1513528417
0
3780854561
0
2411474817
0
1879787649
0
398644769
0
3859808609
0
2723996737
0
2117052865
0
3741171169
0
2323352993
0
1163581185
0
802359553
0
590918561
0
3268577249
0
1787029441
0
2790164033
0
2761299809
0
1962577953
0
3641112193
0
2...

result:

ok 200 lines

Test #32:

score: 10
Accepted
time: 614ms
memory: 6316kb

input:

200 16 200
OXOOOXXOXOXOOOOXOXXXXXOXXOXXOOXOOOXXOOOOXOXOXXXXOXXOOOOXOOXOXOXXOXOOXXOXOXOXOOOXXOXOOOOOOOXXXXOOXOXOOXOOXOOXOOXXXXOOOXOXOOOOXXOOXXOXOXXOXOXOXXOXXXOXOOOXOXXXXOXXOOXOXOOXOOXOOOOOXXXXOXOXOXOXOXOOOXOOOOX
57343
65407
65519
64511
65503
64511
49151
64511
49151
61439
65503
65279
65279
65534
61439...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 200 lines

Test #33:

score: 10
Accepted
time: 311ms
memory: 6236kb

input:

200 16 200
AOAOAXAOAXAOAXAOAOAOAOAXAXAXAXAXAOAOAOAOAOAOAXAOAXAXAOAXAOAXAOAXAOAXAXAXAXAXAXAXAXAOAXAXAOAOAOAXAXAXAXAOAOAOAXAOAOAOAXAOAXAXAXAXAOAOAXAOAXAOAXAXAOAOAOAOAOAOAXAXAXAXAXAOAOAOAXAXAXAXAOAOAXAOAXAXAXAXAXA
31520
59491
7515
26442
43203
4412
54292
6905
19395
39481
27749
56643
61429
51923
31196
17...

output:

0
1102225408
2181070848
0
747520
0
0
949288960
2625937408
2570797056
2352480256
2263777280
1409286144
2195357696
0
0
0
0
0
0
0
0
2798518272
1246593024
3974234112
2230845440
912818176
2970583040
0
0
3687289280
0
3388145664
1892253696
0
0
0
3112173568
0
0
2096627712
2483281920
3926556672
0
0
0
1451753...

result:

ok 200 lines

Test #34:

score: 10
Accepted
time: 97ms
memory: 6184kb

input:

200 16 200
AAAAAAOAAAAAAXAAAAAAOAAAAAAOAAAAAAOAAAAAAOAAAAAAOAAAAAAXAAAAAAOAAAAAAXAAAAAAOAAAAAAOAAAAAAOAAAAAAXAAAAAAXAAAAAAXAAAAAAOAAAAAAOAAAAAAOAAAAAAXAAAAAAXAAAAAAOAAAAAAXAAAAAAXAAAAAAOAAAAAAOAAAAAAXAAAAAAXAAA
52382
9564
25024
51027
20908
54426
57892
13681
49596
56303
28359
7859
63912
58578
50740
5...

output:

0
0
0
3446743897
0
0
0
3579517845
0
116375673
3360612165
1123108825
0
0
0
0
3665728757
597459937
0
833292725
3766041737
0
359636469
435523013
0
0
0
0
0
0
2646344113
0
4072786529
1841934297
2228003597
2901828165
0
2662251305
0
0
4074738853
0
3186713229
960682457
0
3157640929
2414867013
0
0
1256840513...

result:

ok 200 lines

Test #35:

score: 10
Accepted
time: 527ms
memory: 6236kb

input:

200 16 200
XOXOOOAXOOXOOAXOXXOOAXXXXOXAXOOXXXAXOOXXXAXXXOOOAXOOOOOAOXOOXXAXXOOOOAXXOOXOAOXXXXOAXOOOOOAXXXOXOAXXOOOXAOOOXOXAXOOOXXAXXXXOXAOXXXXOAXXXXOOAOOOOOOAOXXOXOAOXOXOXAXOXXOXAXOXXXOAOXOXXOAXOXXOOAXXOXOOAOOX
10282
1585
29289
6570
42702
25836
53015
28198
10069
39731
12780
40571
53594
9191
31505
11...

output:

0
416534272
633290752
0
0
0
3068395520
0
945635328
1276968960
0
638582784
0
1111687168
823607296
2367244032
715063296
0
1829847040
0
0
0
0
0
1307574272
4224974848
0
0
0
4222042112
0
0
0
1436090368
0
0
0
3517890560
3308519424
4034150400
0
2137587712
2954821632
0
0
1142374400
0
0
0
0
3837542400
0
1042...

result:

ok 200 lines

Test #36:

score: 10
Accepted
time: 295ms
memory: 6224kb

input:

200 16 200
XXAAAOXXAAOAAAAAAXXAXXAXXOXOAAAOAOAXOAAAXOXXAAAXAOOAOOXAAXAXAOOOAOXOXAAAOAOOAXAXXOOOAXAAAXXAAXAAAAAAXAXAOXAAOXXOOAOAAAAXAAAXOAXOAAOAAXOOAAAOXAAAOAXAAAAXAXOXOXAXAXAAAOOXXXAAXAXAAXAAAAAAAAOAXAOXAAAAAAA
5792
60020
59739
43873
52052
50193
14658
58866
51983
36700
14033
44909
47996
60685
5167
1...

output:

0
0
2785239271
3810882207
0
1056878721
0
0
2009660665
0
3949685919
90567937
0
2386112449
2961428409
2495474817
1763440377
0
0
0
3490785119
2507289567
3847440121
1686629287
2141936249
233727353
3901966119
2767610279
0
320050271
3764389791
734539969
2793711711
0
3416668601
0
2064153503
0
0
2313730049
...

result:

ok 200 lines

Test #37:

score: 10
Accepted
time: 97ms
memory: 6176kb

input:

200 16 200
AAXAAAXAAAAAAAAAAAAAAAAAOAAXAAAAAXAXAAAAAAAAAAXAAAOAAAAAAAAAAAAAXXAAAAAAAAAAXOAAAAAAAAAAAAAAAAAAAAXAOAAAAAAAAAXAAAAAAAXAAAAAAAAOAAAAAOAAAAAAAAAAOXAXAAAAAAAAAOAAAAAAAAAAAAAOAAXAAAAAAAAAAAOAAAAAAOXAAAO
17281
33709
63144
26567
21976
34669
27038
21387
23582
61016
9215
65030
53987
46383
7218
3...

output:

2350527441
1541948637
0
512402433
0
2650868617
0
4294069601
0
0
3423306317
0
3570244141
1677055569
0
0
0
0
0
2186151325
4221119141
2904509357
84949089
2460779577
4062801565
0
443512641
2107103205
0
3999276365
2743835497
2736841437
0
3274681833
0
938296301
87666877
2445643973
0
0
3234008481
152590537...

result:

ok 200 lines

Test #38:

score: 10
Accepted
time: 527ms
memory: 6172kb

input:

200 16 200
OAXOXXXOXAOAAOXOXOXOOOXOXXXOXOOOOAXOXOXXOXAXOOOXOXXOXOOOOXOOOXXAXOXOXOOAOOOXAXOAOOOAXXXXAOAOAOXAXAXXOAXAOXOXOXOXOOOOXOAOOXXXOXOOXOXAOXOOOOXXOXXOOOXXOOXXXXOOOAOXOOXAAXXXOXXAOOOXOAXOXXOAXOXXXOAXXOXOOAO
14506
9350
45373
63818
11524
21207
53428
56071
24378
60785
45149
10489
43907
61556
53427
...

output:

0
0
2213806080
0
0
325943296
0
2452193280
0
641990656
1243217920
957267968
1547231232
0
2626478080
2363031552
376481792
0
0
0
4253802496
0
0
507183104
0
0
0
884613120
0
0
0
2651455488
905912320
0
3860725760
0
235397120
0
2526150656
2912944128
3863535616
0
3765272576
673054720
331972608
288380928
143...

result:

ok 200 lines

Test #39:

score: 10
Accepted
time: 42ms
memory: 6224kb

input:

200 16 200
AAAAAAAAAAAAAAAAAAAAOAAAAXAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAOAAAAAAOAAAXAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
10507
58474
45019
22501
61419
58351
39893
40185
30389
64429
48700
31377
44886
16299
5981
...

output:

137008075
0
2450650147
563612147
1136526817
2391539547
478037651
3493139899
2561613779
3986361291
0
3623025955
0
1310121257
4286525033
4042222371
2330679353
0
4246430875
1520484865
1935939603
0
0
0
0
1157371323
3468893233
1994235993
2997116641
1285280169
438600361
0
4056806067
247913979
0
3020619457...

result:

ok 200 lines

Test #40:

score: 10
Accepted
time: 572ms
memory: 6276kb

input:

200 16 200
OOXOXOXXOOOXOXXXXOOOOXXOOXXOOOXOXXXXXOOXXOAXXXXXAOOXOXXXOOOXXXXOOOAOOXXXOOXXAXXXOXOXOXXAOOOXXOOXAXOOOOXOOOOOAOOOOAOXXXXOXXXXXOOXXXOXXOXXAXXOAXXOOOOXXXOXOOOXXOXXOXOAXXXXXXOXOXXOXOOOXXXOXXXOXXOOOOAOOOX
41894
21117
9709
22647
16598
57838
47966
63134
59235
31110
59567
60988
20607
50555
26744
...

output:

0
3816816640
2041839616
3929243648
0
0
0
0
2090729472
0
3627679744
0
61702144
3887464448
0
4097048576
0
1691585536
0
0
0
3242905088
3210346496
0
2319056896
0
0
0
0
1149266048
2924085248
25681920
0
3039100928
0
0
0
1539112960
0
1264058368
0
0
3567386624
584581120
3199729664
1860829184
0
0
0
479723520...

result:

ok 200 lines

Subtask #5:

score: 0
Runtime Error

Dependency #3:

100%
Accepted

Test #41:

score: 0
Runtime Error

input:

200 30 1
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
527009106

output:


result:


Subtask #6:

score: 0
Runtime Error

Test #51:

score: 0
Runtime Error

input:

1000 30 1000
XOOXOOXOOXXOXOXOOOXOXXOXOXXXOXXOXOOOXXOXOXOXXXXOOOOXOOXOXXOOOXXOXOOXOOOOOOXOOXOXXOXXXOOXXXOXXXOXXXOOOOXXXOOXXXXXXXXOXOOOOXOOOOXXOXXXXXXXXXOXOOXOOXOOOXXXXXXOOXXOXOOXXOXXXXXOOXOOOXXOOXOOXOXOOOOXXXOXOOXOXOXXXXOOXOXOOXXXXXOXOOXXXXXOXXOXOXXOXOOXOXOOOOXXOXOOXXXXOOXXOXXOOXXXXOXXOOXXXOOXOOOXOXO...

output:


result:


Subtask #7:

score: 0
Runtime Error

Dependency #2:

100%
Accepted

Test #61:

score: 0
Runtime Error

input:

50 30 50
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
1073741823
1073741822
1073741821
1073741820
1073741819
1073741818
1073741817
1073741816
1073741815
1073741814
1073741813
1073741812
1073741811
1073741810
1073741809
1073741808
1073741807
1073741806
1073741805
1073741804
1073741803
1073741802...

output:


result:


Subtask #8:

score: 0
Skipped

Dependency #5:

0%

Subtask #9:

score: 0
Skipped

Dependency #4:

100%
Accepted

Dependency #5:

0%

Subtask #10:

score: 0
Skipped

Dependency #6:

0%