QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#608508#4999. AibohphobiA3un_larryfuncAC ✓11ms7220kbC++144.1kb2024-10-03 22:19:202024-10-03 22:19:22

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5832kb

input:

3
3 5
abbba
bccab
cabcc
2
0 1
1 0
3 4
aaba
bbaa
abab
1
1 1
4 4
abca
cxxb
bxxc
acba
1
0 1

output:

9
9
-2
-1

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 4760kb

input:

20
2 5
bacba
aabbc
3
0 3
1 4
1 2
2 5
aacba
cbbac
8
0 3
1 2
1 2
1 0
1 2
0 2
0 0
0 0
4 4
aaac
caab
babb
ccba
8
2 0
3 2
2 1
2 1
1 3
2 2
1 2
3 1
4 3
bbb
ccc
abc
caa
3
2 0
0 0
3 2
3 3
cba
abc
bac
4
0 1
0 1
1 0
1 1
4 4
bcab
caba
cbcb
abca
1
1 1
5 4
baba
caba
aacb
abcb
caab
1
4 2
2 3
cab
aac
5
0 0
0 2
0 1
...

output:

6
6
-2
8
8
8
8
8
8
8
8
7
7
7
7
-2
-2
-2
7
6
6
6
-1
-1
-1
-1
9
10
4
4
4
4
4
8
8
8
-2
8
8
8
8
6
-2
-2
-2
-1
-1
-1
-2
-2
7
-2
-2
6
6
-2
6
6
6
6
6
-2
4
4
4
-2
-2
-2
8
-2
8
-2
-2
-2
8
8
-2
8
5
5
5
5
-2
5
-2
5
5
5
5
5
-2
-2
5
5
-2
7
-2
-2
-2
7
7
5
-2
5
-2
-2
-2
-2
5

result:

ok 109 lines

Test #3:

score: 0
Accepted
time: 1ms
memory: 5880kb

input:

20
5 3
nwt
nwn
ntn
wwt
tnw
1
3 0
5 2
xl
ll
ix
il
xi
3
1 1
0 1
3 1
5 5
sllol
solss
osssl
lloso
llolo
10
2 3
2 1
0 0
3 2
3 1
0 1
3 0
0 0
0 3
0 4
2 4
tsts
sets
8
1 1
1 2
1 3
1 1
0 1
0 3
0 3
0 1
3 5
gcczg
zcccc
cgzcg
2
2 0
1 4
4 3
prh
prp
phr
pph
3
0 1
0 0
2 0
5 2
mn
ml
mm
nn
nl
7
2 1
3 1
0 1
1 0
0 0
1 ...

output:

-1
-2
-2
6
-2
-1
-1
-1
-1
-1
-2
-1
-2
-2
5
5
5
5
5
-2
-2
5
7
-2
6
6
-2
6
6
6
-2
6
-2
-2
6
-2
6
-2
-2
-1
-1
-1
-1
-2
-2
-2
-2
-1
-2
8
4
-2
4
-2
4
4
4
4
-2
4
-2
-2
-1
-1
-1
-2
-1
-2
9
9
9
-2
9
-2
-2
-2
9
5
-2
-2
-2
5
-2
-2
9
9
9
-2
9
9
-2
-1
-1
-1
-1
8
-1
-1
-2
-2
-2
-1
-1
-1
-1

result:

ok 105 lines

Test #4:

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

input:

20
100 100
upluplupluplupluplupluplupluplupluplupluplupluplupluplupluplupluplupluplupluplpppppppppppppppppppppp
uppppppppppppplpppppplppppppupppppppppppppppppppplpppppppppppppppppppppppppppupppppppppppppppppppppp
ppppppppppppppuppppppupppppplppppppppppppppppppppuppppppppppppppppppppppppppppppppppppp...

output:

227
-2
-2
-2
-2
227
-2
-2
-2
227
227
-2
-2
-2
-2
-2
227
-2
227
-2
-2
-2
-2
-2
-2
-2
-2
-2
227
-2
-2
227
227
-2
-2
227
227
-2
227
-2
227
-2
227
227
227
227
-2
-2
227
-2
-2
-2
227
-2
227
-2
215
-2
-2
-2
-2
-2
227
-2
-2
-2
-2
-2
227
-2
-2
227
227
215
227
227
227
-2
227
227
-2
227
-2
215
-2
227
-2
-2
-2...

result:

ok 2000 lines

Test #5:

score: 0
Accepted
time: 11ms
memory: 7176kb

input:

20
100 100
dbdmbdmbdmbdmbdmbdmbdmbdbdmbddmbbdmbdmbdbdmbdmbdmmbdmdmbddddddddddddddddmbdmbdmbdmbdmbdmbdmbdmbdmbdm
mdddmdddmdddddddddddbdddmdddmdddmdddbdddmdddddddbdddbdddmddddddddddddddddddddddddddddddddddddddddddb
bdddddddbdddddddddddddddddddbdddddddddddddddddddddddddddbdddddddddddddddbdddddddddddddd...

output:

-2
-2
-2
-2
-2
301
-2
-2
301
-2
-2
-2
301
-2
-2
301
-2
-2
-2
-2
-2
301
-2
-2
301
301
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
301
-2
-2
301
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
301
-2
-2
-2
-2
301
-2
-2
-2
-2
-2
301
301
-2
-2
301
-2
-2
-2
-2
301
-2
-2
-2
-2
301
-2
-2
-2
-2
-2
301
-2
301
...

result:

ok 2000 lines

Test #6:

score: 0
Accepted
time: 1ms
memory: 5904kb

input:

20
10 10
iytyiityii
ytyttyyiii
ttiyttityt
iyyttyiyty
yyiiytiytt
ytiityttiy
tiytyyytyy
iyiiytyitt
iiitiytity
itityytyti
81
6 8
6 0
3 3
4 2
3 7
7 1
9 7
6 4
3 5
2 5
5 5
5 2
2 9
3 5
8 9
3 8
8 3
5 5
9 7
7 3
9 4
7 4
6 5
0 8
0 8
5 3
4 7
4 5
9 4
0 8
0 9
8 7
6 9
5 3
6 8
7 4
5 9
5 4
9 7
4 8
3 7
8 8
6 8
8 8
8 ...

output:

-1
-2
-1
-2
-2
-2
-1
-2
-2
-2
-2
-2
-2
-2
-1
-2
-2
-2
-1
-2
-2
-2
-2
-2
-2
-2
-1
-1
-2
-2
-2
-1
-2
-2
-1
-2
-2
-2
-1
-1
-2
-1
-1
-1
-2
-1
-2
-1
-1
-2
-2
-1
-1
-2
-2
-1
-2
-1
-2
-2
-2
-2
-2
-1
-1
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-1
-1
-2
-2
-1
-1
-2
-1
-1
-1
-1
-2
-2
-1
-1
-1
-2
-2
-1
-2
-2
-2
-1
-2
...

result:

ok 1358 lines

Test #7:

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

input:

20
30 30
cabacbacbacbacbacbacbacbacbaaa
bacaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaacaaa
cabaaaaaaaaaaaaaaaaaaaaaaabaaa
bacaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaacaaa
aaaaaaaaaaaaaaaaaaaaaaaaaabaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaacaaa
aaaaaaaaaaaa...

output:

-1
-1
-1
-1
-1
-2
-1
-1
-2
-2
-1
-1
-1
-1
-2
-1
-1
-1
-1
-1
-1
-2
-1
-1
-1
-2
-2
-1
-1
-1
-1
-2
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-2
-1
-1
-1
-1
-1
-1
-1
-2
149
149
149
149
149
149
149
149
-2
149
149
149
149
-2
149
149
149
149
149
149
149
149
149
149
149
149
149
-2
149
149
149
149
149
149
149
149
149
-2...

result:

ok 1000 lines

Test #8:

score: 0
Accepted
time: 2ms
memory: 6036kb

input:

20
30 30
caaaaaaaaaaabacbacbaaabacbacba
baaaaaaaaaaacaaaaaaaaacaaaaaac
aaaaaaaaaaaaaaaaaacaaaaacabcab
caaaaaaaaaaabaaaaabaaababaaaaa
baaaaaaacbaacaaaaaacbacaaaaaaa
aaaaaaaaaacaaaaaaaaaaaaacaaaaa
caaaaaaabababaaaaaaaaaaabaaaaa
baaaaaaacaaacaaaaaaaaaaaaaaaaa
aaaaaaaaaacaaaaaaaaaaaaacaaaaa
caaaaaaababa...

output:

153
-2
-2
-2
141
-2
-2
153
153
-2
-2
153
-2
-2
-2
-2
153
153
153
153
-2
-2
-2
153
-2
141
153
153
153
-2
153
-2
-2
153
153
153
-2
153
153
153
153
153
153
-2
-2
-2
153
153
153
153
-1
-1
-1
-1
-2
-1
77
-2
77
-2
-1
-2
-2
-1
-1
-1
-1
77
-2
-2
-1
-1
-1
-1
-1
77
-1
-2
-1
-2
-1
-1
-1
-2
-1
-2
-1
-1
-1
-1
-1...

result:

ok 1000 lines

Test #9:

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

input:

20
100 100
acbacbacbacbaaaaaaaaaacbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaacaaaaacaaaaaaaabaacaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaabaaaaabaaaaaaaacaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

685
613
685
685
685
685
685
-2
685
685
613
685
685
685
685
613
-2
685
685
-2
685
685
685
685
685
685
685
685
-2
685
-2
685
655
-2
685
685
685
685
685
685
685
397
613
685
685
685
397
685
685
685
-2
613
685
685
685
679
685
-2
613
-2
685
685
-2
613
685
685
685
685
685
685
673
685
685
685
613
613
397
68...

result:

ok 2000 lines

Test #10:

score: 0
Accepted
time: 7ms
memory: 7180kb

input:

20
100 100
dvtdvtdvtdvtdvtdvtdvtdvtdvtdvvvvvvvvtdvtdvtdvvvvvvvvvvvvvvvvdvtdvtdvtdvtdvvvvvvvvvvvtdvtdvvvvvvvvvvv
vvvvtvvvvvvvvvvvvvvvvvvvvvvvtvvvvvvvvvvvvvvvtvvvvvvvvvvvvvvvtvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
tvvvdvvvvvvvvvvvvvvvvvvvvvvvdvvvvvvvdvvvvvvvdvvvvvvvvvvvvvvvvvvvvvvvvvvvtvvvvvvvvvvvdvv...

output:

-1
-1
-1
-2
-1
-2
-1
275
-2
-2
275
-2
275
-1
-1
-1
-2
-1
-1
-1
-2
-2
-1
-1
-1
-1
275
-1
-2
-1
-2
-2
275
-2
-1
-1
-2
-1
-2
-1
-2
-2
-1
-1
-1
-1
-1
-1
-1
-1
-2
-1
275
-1
-2
275
-1
-1
-1
-1
-1
-2
-2
-2
-1
-2
-1
-1
-2
275
-2
-2
-2
-1
-1
-1
-1
-1
-2
275
-1
-1
-1
-2
-2
-1
275
-1
-2
-1
-1
-2
-2
-1
-2
-1
-2...

result:

ok 2000 lines

Test #11:

score: 0
Accepted
time: 9ms
memory: 7080kb

input:

20
100 100
sozsozsozsozsozsozsozsozsozsozsozsozssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
osssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
zssssssssssssssssssssssssssssssssssosssssssssssssssssssssssssssssssssssssssssssssssssss...

output:

-2
367
367
367
367
367
-2
367
-2
367
-2
-2
-2
367
-2
-2
-2
367
367
-2
367
277
-2
-2
367
-2
-2
-2
-2
367
367
367
-2
-2
-2
367
-2
367
-2
367
-2
367
367
277
-2
367
367
-2
-2
-2
367
277
367
-2
367
367
367
367
-2
-2
367
-2
-2
367
367
-2
-2
367
277
367
367
367
367
367
-2
367
367
367
-2
-2
367
367
367
-2
3...

result:

ok 2000 lines

Test #12:

score: 0
Accepted
time: 7ms
memory: 6832kb

input:

20
100 100
nhhhunhunhunhunhunhunhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
uhhhnhhhhhhhhhhhhhhhuhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh...

output:

515
-2
-2
-2
-2
-2
-2
-2
-2
515
-2
515
515
-2
-2
515
-2
515
-2
515
-2
-2
-2
515
515
515
515
-2
-2
515
515
515
515
-2
-2
-2
515
515
515
413
-2
515
515
-2
515
-2
515
515
515
515
515
515
-2
-2
-2
-2
515
515
515
515
-2
-2
-2
-2
515
-2
515
-2
515
-2
515
515
-2
-2
515
-2
515
-2
515
515
515
-2
-2
-2
-2
515...

result:

ok 2000 lines

Test #13:

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

input:

20
100 100
kqukqukqukqukqukqukqukqukqukqukqukqukqukqukqkqukqqukqukqukqukqukqukqukqukqukqukqukqukqukqukqukqukkkk
kkkkkkkkkkkkkkkkkkkkkkkkqkkkkkkkkkkkkkkkkkkkukkkukkkkkkkqkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkqkkk
kkkkkkkkkkkkkkkkkkkkkkkkukkkkkkkkkkkkkkkkkkkqkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk...

output:

-2
523
523
523
523
523
-2
-2
523
493
523
445
523
523
523
445
445
523
523
523
445
523
523
523
523
523
523
523
-2
-2
445
523
-2
445
523
445
-2
523
523
523
445
-2
-2
-2
523
-2
445
445
523
523
523
445
523
445
523
445
523
445
523
-2
445
-2
523
445
-2
523
523
523
523
523
-2
523
-2
-2
-2
445
-2
493
523
523...

result:

ok 2000 lines

Test #14:

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

input:

1
10 10
abcabcabca
aaaaaaaaab
aaaaaaaaac
acbacbacba
baaaaaaaaa
cabcabcabc
aaaaaaaaaa
bcabdaaaab
aaaaaaaaac
dcbacbacba
6
0 0
3 3
4 5
2 9
9 9
8 1

output:

59
59
-2
59
59
-2

result:

ok 6 lines