QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#797793#9647. 数位 DPDanielQOJ20 650ms106804kbC++143.7kb2024-12-03 18:34:112024-12-03 18:34:12

Judging History

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

  • [2024-12-03 18:34:12]
  • 评测
  • 测评结果:20
  • 用时:650ms
  • 内存:106804kb
  • [2024-12-03 18:34:11]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ui unsigned int
int n, k, q;
string s;
int a[1005];
ui ksm(ui x, int y){
    ui ans = 1;
    while(y){
        if(y&1)ans = ans * x;
        y >>= 1;
        x = x * x;
    }
    return ans;
}
int c[1005];
ui ans;
int m;
// unordered_map<int, ui> dp[1005];
ui dp[1005][1<<17];
// ui dp[1005][1<<16];
ui KSM[1005][105];
// ui ANS[55][1<<16][17];
// bool vis[55][1<<16][17];
int ord[1005];
ui calc(int n, int m, int K, int bh){
    // if(vis[ord[n]][m][K]){
    //     return ANS[ord[n]][m][K];
    // }
    ui ans = 0;
    for(int i = (n?min(31/n,K - 1):K-1); i >= 0; i--){
        if(m>>i&1){
            int num = __builtin_popcount(m>>i+1);
            if(1ll * i * n < 32){
                ans += ((ui)1 << i * n) * KSM[bh][num];
            }
        }
    }
    ans = -ans;
    if(1ll * K * n < 32)ans += (ui)1<<K*n;
    return ans;
    // vis[ord[n]][m][K] = 1;
    // return ANS[ord[n]][m][K] = ans;
}
unordered_map<int, int> mp;
int zh(int x, int y){
    if(!x)return 0;
    if(mp[x]){
        return mp[x];
    }
    int wei = 0;
    int ans = 0;
    for(int i = 0; i < k; i++){
        if(y>>i&1){
            if(x>>i&1){
                ans |= (1<<wei);
            }
            wei++;
        }
    }
    return mp[x] = ans;
}
signed main(){
    // freopen("dp.in", "r", stdin);
    // freopen("dp.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin >> n >> k >> q;
    cin >> s;
    int ok = 1;
    for(auto i : s){
        if(i == 'A')ok = 0;
    }
    if(ok){
        while(q--){
            cin >> m;
            int bh = -1, K = k;
            ui ans = 0;
            for(int i = (n?min(31/n,K - 1):K-1); i >= 0; i--){
                if(m>>i&1){
                    int num = __builtin_popcount(m>>i+1);
                    if(1ll * i * n < 32){
                        ans += ((ui)1 << i * n) * (bh==-1?ksm(n,num): KSM[bh][num]);
                    }
                }
            }
            ans = -ans;
            if(1ll * K * n < 32)ans += (ui)1<<K*n;
            cout << ans << '\n';
        }
        return 0;
    }
    vector<int>vec;
    set<int>st;
    for(int i = 1; i <= n; i++){
        int en = i;
        while(en + 1 <= n && s[en-1] != 'A')en++;
        vec.emplace_back(en - i + 1);
        i = en;
    }
    for(int i = 1; i <= vec.size(); i++){
        for(int j = 0; j <= k; j++){
            KSM[i][j] = ksm(vec[i-1] - (i!=1), j);
        }
        st.insert(vec[i-1]-(i!=1));
    }
    vector<int>vecc;
    for(auto i : st){
        vecc.emplace_back(i);
        ord[i] = vecc.size() - 1;
    }
    while(q--){
        cin >> m;
        for(int i = 0; i <= vec.size(); i++){
            for(int j = m; ; j = (j-1) & m){
                dp[i][zh(j,m)] = 0;
                if(!j)break;
            }
        }
        dp[vec.size()][zh(m,m)] = 1;
        for(int i = vec.size(); i >= 1; i--){
            for(int j = m; ; j = (j-1) & m){
            // for(int j = 0; j < (1<<k); j++){
                if(!dp[i][zh(j,m)]){
                    if(!j)break;
                    continue;
                }
                for(int w = j; ; w = (w-1) & j){
                    int pw = w==0?k:__lg(w&(-w));
                    int num = __builtin_popcount((j^w) >> pw);
                    dp[i - 1][zh(w,m)] += dp[i][zh(j,m)] * KSM[i][num] * calc(vec[i-1] - (i!=1), (j^w) & (1<<pw)-1, pw, i) * (i==1?1:(ui)(((ui)1<<k)-w));
                    if(!w)break;
                }
                if(!j)break;
            }
        }
        cout << dp[0][0] << '\n';
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

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: 1ms
memory: 3652kb

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: 0
Wrong Answer
time: 1ms
memory: 5656kb

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
665196
327680
114300
890624
597924
597924
668702
305790
63060
281568
39104
668702
172032
228864
228864
902304
24642
1013855
665196
975600
909800
668702
63060
902304
123552
550400
69632
281568
228864
1048576
550400
632544
144060
665196
902304
24642
39104
123552
114300
228864
305790
9934...

result:

wrong answer 3rd lines differ - expected: '599340', found: '665196'

Subtask #2:

score: 0
Wrong Answer

Test #11:

score: 10
Accepted
time: 3ms
memory: 13856kb

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: 0ms
memory: 3624kb

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: 0
Wrong Answer
time: 2ms
memory: 9984kb

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
2727429240
1995656860
1794163992
0
4237707188
3783262208
1396280088
1531570654
122600516
2757493016
1673181752
1396280088
0
803697752
1541406720
3965333972
1541406720

result:

wrong answer 4th lines differ - expected: '3394047424', found: '2727429240'

Subtask #3:

score: 10
Accepted

Test #21:

score: 10
Accepted
time: 650ms
memory: 106804kb

input:

200 16 1
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
65535

output:

1

result:

ok single line: '1'

Test #22:

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

input:

200 16 1
OXOXXXOXXOXOXXOOOXXXXOOXXOOOXOOXOOXXOOOOXXOXOOXOXXXOXXXXXXXOXOXOOXOXXOOOXOOXXOOOXXXXOXXXOOXXOXOXOXXOOOOOOOOOOXXOXXXOXXOOOXOOXXXOOXXOXXOOOXOOOXOOOXOXXXXXOXOOOXXXXOXXXOOOOOOOXOOXOXXXXXOXOXOXOOXXXOXXOXX
63487

output:

0

result:

ok single line: '0'

Test #23:

score: 10
Accepted
time: 3ms
memory: 54852kb

input:

200 16 1
AXAXAXAOAOAXAXAOAOAXAXAOAOAOAXAOAOAOAXAOAOAOAOAXAXAOAOAXAOAOAOAXAOAXAXAOAOAOAXAOAXAOAXAOAOAOAOAXAXAXAXAXAXAOAXAOAOAOAOAXAXAOAXAXAOAXAXAOAXAOAOAXAOAOAXAXAOAXAOAXAOAOAOAOAOAOAOAOAXAXAOAOAOAOAOAOAXAOAOA
4359

output:

2017260928

result:

ok single line: '2017260928'

Test #24:

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

input:

200 16 1
AAAAAAOAAAAAAOAAAAAAXAAAAAAOAAAAAAXAAAAAAXAAAAAAXAAAAAAXAAAAAAOAAAAAAXAAAAAAXAAAAAAXAAAAAAOAAAAAAXAAAAAAOAAAAAAXAAAAAAOAAAAAAOAAAAAAOAAAAAAXAAAAAAOAAAAAAXAAAAAAOAAAAAAOAAAAAAOAAAAAAXAAAAAAXAAAAAAOAAA
8276

output:

0

result:

ok single line: '0'

Test #25:

score: 10
Accepted
time: 22ms
memory: 20272kb

input:

200 16 1
OOOOXOAOXXXOOAXXOOXOAXOXOXXAOOXXOXAXXXOOOAXOXOXOAOXXXOOAXXOOXXAOXOXOXAOXXOXXAOOOXOOAXOOXOOAOOOXXXAOXOOXOAOOOOOXAXOOOXOAXOXOOOAOXXOXXAOOOXOXAOOOOOOAOXXXOOAOOOOXXAOXOOXOAXXOXXXAXXXXOOAOOXXXXAOOXOOXAOOX
62733

output:

118423552

result:

ok single line: '118423552'

Test #26:

score: 10
Accepted
time: 24ms
memory: 61220kb

input:

200 16 1
XAXXAAOAOAOXOXAAAXAAXAAAXOAXAAXOXOAOAXOOAAAAAXAAOXAAAOOAOAAXAXXXOAOOOOXAAXAAAOAXOAAAXAAAAAAXOAAAAXAAOAAAAAOAAXOAOOXXAOAXOOAAAAOAAAAAAAAXXAAOAOOXAOAOAAAAAAAXAAXOAAOOAAXAAAXAAOAAXAXOXAXXXXOXXAOAAOAOAAA
36975

output:

3800841600

result:

ok single line: '3800841600'

Test #27:

score: 10
Accepted
time: 107ms
memory: 85684kb

input:

200 16 1
XAAXAXAAAAAXXAOAAOXAAAAXAAAAAAAAAAXOAAAAAAAXAAAAAAAOAAAAAOAAAAAAAAAOAAAAAOAAAAAAAAAAAAAAAAAAAAXAAAOOXAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAXAAOAAAAAAAAAAAAAAAOAAAAAXAAAAAAAAAAAAAAAAAAAAAAAXOAXAAAAAXAAAAAA
42961

output:

4143734528

result:

ok single line: '4143734528'

Test #28:

score: 10
Accepted
time: 191ms
memory: 18644kb

input:

200 16 1
XOOOXXXXOXXAOXXAOOXXOXAOXOOAOOOOAAXOAXOXXAOOOXXOOXOXOOXOXOXXXAOXOXOXOXXXAXOAOXXXOOOXXXXXOOOOOOXAOXXXAXOXXAOOOXXAOXOOXOOXOXXOXOXOOAOXOOAXAXXOXAOXXXXOOXAOXXOOXXOXAOOOOAXXAOOOXXOOXOOOXAOXXOXOAOXOXAOXOXX
32762

output:

0

result:

ok single line: '0'

Test #29:

score: 10
Accepted
time: 361ms
memory: 91980kb

input:

200 16 1
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAXOAAAXAAXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAXAAAAAAAAAAAAAAAAAAAOAAAAOAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAOAAAAAAAAAAAAAAAA
55979

output:

347602944

result:

ok single line: '347602944'

Test #30:

score: 10
Accepted
time: 6ms
memory: 16208kb

input:

200 16 1
AXXOOOOXOOOOOXOXOAXOOXOXOXAOXOOXXXOXOAOOAOOAOXOAOXXXXOXAAOXOOXXXXAOOOXOXOXXOAOXXOXOXXXXXOOXAXOOXOOOOOOXXXXOOXOOOOOXOXOOXXOOXOXXXXOOOAXXOXOAOOXXOOXAOXXOXOXOXXXOOAXOXXAXOOAXXXOXAOOOXXOOOAOOOXOAXOXOXOXO
30929

output:

3913125083

result:

ok single line: '3913125083'

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Time Limit Exceeded

Dependency #3:

100%
Accepted

Test #41:

score: 10
Accepted
time: 275ms
memory: 96540kb

input:

200 30 1
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
527009106

output:

0

result:

ok single line: '0'

Test #42:

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

input:

200 30 1
OXXOXOOXOXOXXXOOOXXOOOXXOOXOXXOXXOXXOXXXOOXXOXXOXXXXXXXXXOXXXXOXXOXOOXOXOOXXXOXXOOXOXXXOXXXOOXOXXOOXXXXOXXXOXXXXXOXOXXXXXOXOXXXXXOOXOOOOOOXXXXXXOOXXOOXOXXXXXXXXOXXOOXOXXXXOOXOOOOOXOOXXXOOXOOOOXOOXXXO
388762601

output:

0

result:

ok single line: '0'

Test #43:

score: 0
Time Limit Exceeded

input:

200 30 1
AOAXAOAXAOAXAOAOAOAXAXAXAXAOAXAXAXAOAOAXAXAOAXAOAXAOAOAOAOAOAOAOAOAXAXAXAOAOAOAXAXAXAXAXAOAXAOAOAOAXAXAXAXAOAXAOAXAOAOAOAXAOAXAXAOAOAXAOAXAOAXAXAXAOAXAXAOAXAXAOAXAOAOAOAOAXAXAOAXAXAXAOAOAXAXAOAXAXAOA
654399953

output:


result:


Subtask #6:

score: 10
Accepted

Test #51:

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

input:

1000 30 1000
XOOXOOXOOXXOXOXOOOXOXXOXOXXXOXXOXOOOXXOXOXOXXXXOOOOXOOXOXXOOOXXOXOOXOOOOOOXOOXOXXOXXXOOXXXOXXXOXXXOOOOXXXOOXXXXXXXXOXOOOOXOOOOXXOXXXXXXXXXOXOOXOOXOOOXXXXXXOOXXOXOOXXOXXXXXOOXOOOXXOOXOOXOXOOOOXXXOXOOXOXOXXXXOOXOXOOXXXXXOXOOXXXXXOXXOXOXXOXOOXOXOOOOXXOXOOXXXXOOXXOXXOOXXXXOXXOOXXXOOXOOOXOXO...

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 1000 lines

Test #52:

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

input:

1000 30 1000
XXOOXXXOOOXOXXXXOOXXXXXOXOOXOXXOXXXOXXOXOOOOXXXXOOXXXOOXXXOOOXOOOOOXOOOOXXXXOXXOXOOXXOXXXOXOOXXOXOXOXOXOOOOXOOOXXXOOOOOOOOOXXOOOOOXOOXOOXOOXXXOOOXXXOXOOOXXXOOOXXOOXOOOXXXOXOOOXOXXOXXXOOOOXOXXOOOOOXOOOOOXXOXOOXXOXOXXOOXXOXXXXXXXXOOXOOOOXXOOXXXOOXOXXOXOXOXXXXOOOXXOOXXOOXXOOXOXOOXXOOOXXXOX...

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 1000 lines

Test #53:

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

input:

1000 30 1000
XXOXOXXOOOXXXOXXXOXOOXXOOXXXXOXOOOXXXXOOOOOXOOOOOOOXOXOOXXOOXXOOOXOXXXOOXXXXXXOXXXOOOOXXOXOXOOXXOOOXXOXOXOOOOXXXXOOXXXXXOOXOOXOXXOXXXXOOXOXOXOXOOOOOOOOOOXXOOOXXOXXXXXOXOXOXXXOXOXXOXXXXOOOOOOXOOXOOXXOOOOOOOOXXXXOXOOXOOOOOOXOOXXXXOXXOOXXOXXXXXXXXOXXXXOOOXXXXOOXOOXOXXOOOOOXOOXXXXOOXXOOXOOO...

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
402653184
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
3221225472
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 1000 lines

Test #54:

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

input:

1000 30 1000
XXOXXOXXOXOXXXXXOXXOXOOXXXOXXOXXOOOOOXXXXOXOOOXOXOXXXOXXOOOXXOXXXOXXOOOOXXOOXOXXOOOOXOOXXXOOOXOXOXOXXOOXXXOOOXXOXXOXXOOXOXOXXXXXOOXXXOOOOXXXOXOXXOXOOXOOOXXOXOXOOXXXXOOXXOOOOOXXXOXOXXOXOXOXOOXXXXOXOXOOOXOXXOOOOXOXOOXOOXXXXXOXOXOOXOXOOXOOXOXOOOXOOXXOOXXXOOXOXOOOXOOOXXXOOXOXOOXXOOOXXOOOXOO...

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
3221225472
0
0
0
0
0
0
0
0
0
0
0
0
3221225472
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 1000 lines

Test #55:

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

input:

1000 30 1000
OOOXOOXOOXXOOXOOOOXXXXXXOOXXOXOOOXXXXOOOOXOXXXXOXOXOOXOXXXXOXOOXXOXOXXOXXXOOOOOOOXXXOXXOOOOXOOOOXOOXXOOXOXXOXOOOXOOXOXXXXOXXXOOOOXXOOXXOXXXXOOXOXOXXOOOOXXOOOOXOOXXOOOOXOOXXXXOXXOOOXXXXXOOXOOOXXXOOXOXXOOXOOOOOOOXXOXXXXXOXOXOXXXOOOXOOOXXOXXOOOXXOOOOXXOOXXOXOOXXXOOXOXXXOOXXOXXXXXOXOOOOXXXX...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
402653184
3221225472
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
1593835520
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
1530494976
0
0
0
0
0
0
0
0
0
0...

result:

ok 1000 lines

Test #56:

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

input:

1000 30 1000
XOOOOOXOOOOXXOXXXOXXXXXXXXXXOXOOXXXXXXXOXXOOOXXOXXXXXXXXXOXXXXOXXOOOXOOOXXOXXOXOOOXXXOXXOOXOOOXOOOXOOOXOXOXXXXXOOOOXOOOOXXXOXOOOXXXOOXXOOXOXXXOOXOXOOXXXOXOXXOXXXXOXXXOOXOOOOXXXXOOOOXXOOXXXXOXOXOOOXXOXOOXOOXOXXXOXOOXOXOXOXOOOXXXXOXOOXXOOXOOXOXXOOOXXXXOOOOXXXOOXXXXOOOOXXXXXXXXOXOXOOXXOXXO...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3221225472
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
3221225472
0
0
0
0
3221225472
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 1000 lines

Test #57:

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

input:

1000 30 1000
XOXXXOXOOOOOOXOOXOOOOOXXXXXOOOXXXOXOXOXXOOOXXOOXXOOXOOOOOXOXXXXOXOOXOOXOXXXOOXOXOXOOXXXXXXXOXOOOOOOXXXOXOXOOOOOOXXXXXOOXXXXXXXXOXOOOOOXXOXOXOXOOOOXOXXOOOOXOOOXXOOXOXXOOOOOXXOOXOXOOOXOOXOOOXOOOOXXOXXXOOOOXXXOXOXXOXOOXXXXXOOOXOXXOXOXXOXXXOOOXXXXXOXOOXXOXOXOXXXOOXOOXXOOXXXXOOOOOXXXXOXOOXOO...

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
3221225472
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
3221225472
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 1000 lines

Test #58:

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

input:

1000 30 1000
XOOXOXOOOXOOXXXXOOOOOXXXXOOXXXOOOXXXOXXOOXXXOOOOOOXOOXXOOXXOOOOOOXXXXXOXOXOOOXOXOOXOOXXOOXOXOOXOOOOXOOXOOXXOOXXOXOOXXOXXXOOXOXXXXOOOOXXOOXOXOXOOOXOXOXOXOOOOOOOOOOOXOXXXOOXXOXXOOOOOXOXOXXXOXXOOOXOXXOXXXOXOOXXOXOOOXXOOXXXXOXXXXOOXXXOXXOOXOXOXXXXOXXXXOOOOOXOOXXXXXXOXXOOOXXOOXXXXXXOXXOOOXOO...

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
1593835520
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 1000 lines

Test #59:

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

input:

1000 30 1000
OXXOOXOXOXOOXOOOXXOOXXXXXXOXOXOOOOXXXOOXXXOXXXOXXXOXXOOXXOXOXXOOXOXXXXXOOXOOXOXOOXXXXXOOOOXOXOOOXXXOOOOOOOXOXOXXXXXXOOXOXOOOXXXXOXOXXOOXXOXOOOXXXOXXXOOOOOXXOXXOOOXXOXXXOXXOXXXXXOOOOXXXXOXOXOOXXOXXOOOOOOXXOXXXXXXOXOXOOXOXOXOOXXOOOXOXOOOXXOXOOXOOOXXOXXOXXOOXXOXXXOXOXOOXXXXXOOXOOXXXXOXXOOX...

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 1000 lines

Test #60:

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

input:

1000 30 1000
XXXOOOXXXXXOXOXXXOXOXOOXOXOXXOXOOXXOOXXOXOOOOOXXOOXXOOOOOOXXOXXXOOOOXXXOOXXXXOXOXXXOOOOXOXXOOXOXXXOXXXOXXOOXOXXOXOXOXOOOOOXXOOOXOOOXOOOOXOOXOOXOXOOXOOOOOOOXOXOOXOXOOOOXOOOXXOOXXXOXOOXXXXXXOXOXOOXOOXXXXXXXOOOXOOOXOOOOXXXOXOOXXXXXXOOXOOXXOOOOXOOOXOXXOXOXOXXOXOOOOOOXOXXOXOXXOXXOXXOOXXXXOXX...

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
3221225472
0
3221225472
0
0
0
0
0
0
0
0
0
0
0
3221225472
0
0
402653184
0
0
0
0
0
0
0...

result:

ok 1000 lines

Subtask #7:

score: 0
Skipped

Dependency #2:

0%

Subtask #8:

score: 0
Skipped

Dependency #5:

0%

Subtask #9:

score: 0
Skipped

Dependency #4:

0%

Subtask #10:

score: 0
Skipped

Dependency #6:

100%
Accepted

Dependency #8:

0%