QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#793300#7668. Game Strategyucup-team4744#AC ✓140ms7292kbC++201.1kb2024-11-29 18:25:162024-11-29 18:25:17

詳細信息

Test #1:

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

input:

2
2 ab b
1 b

output:

0 1
-1 0

result:

ok 2 lines

Test #2:

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

input:

3
1 b
2 b a
2 ab ac

output:

0 1 -1
1 0 -1
2 2 0

result:

ok 3 lines

Test #3:

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

input:

1
1 a

output:

0

result:

ok single line: '0'

Test #4:

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

input:

1
1 a

output:

0

result:

ok single line: '0'

Test #5:

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

input:

3
7 a b ab c ac bc abc
6 a abc ab c ac bc
2 ac c

output:

0 1 1
1 0 1
-1 -1 0

result:

ok 3 lines

Test #6:

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

input:

25
1 b
1 c
1 d
1 e
1 f
1 g
1 h
1 i
1 j
1 k
1 l
1 m
1 n
1 o
1 p
1 q
1 r
1 s
1 t
1 u
1 v
1 w
1 x
1 y
1 a

output:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
24 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
23 24 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
22 23 24 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
21 22 23 24 0 1 2 3 4 5 6 7 8 9 10 11 12...

result:

ok 25 lines

Test #7:

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

input:

2
1 a
2 a ab

output:

0 -1
1 0

result:

ok 2 lines

Test #8:

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

input:

25
1 a
1 b
1 c
1 d
1 e
1 f
1 g
1 h
1 i
1 j
1 k
1 l
1 m
1 n
1 o
1 p
1 q
1 r
1 s
1 t
1 u
1 v
1 w
1 x
1 y

output:

0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -...

result:

ok 25 lines

Test #9:

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

input:

3
4 a b bc c
5 a b bc c ac
6 a abc ab c ac bc

output:

0 1 1
1 0 1
1 2 0

result:

ok 3 lines

Test #10:

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

input:

20
20 a b c d e f g h i j k l m n o p q r s t
20 a b c d e f g h i j k l m n o p q r s t
20 a b c d e f g h i j k l m n o p q r s t
20 a b c d e f g h i j k l m n o p q r s t
20 a b c d e f g h i j k l m n o p q r s t
20 a b c d e f g h i j k l m n o p q r s t
20 a b c d e f g h i j k l m n o p q r ...

output:

0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 0 1 1 ...

result:

ok 20 lines

Test #11:

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

input:

2
3 a b ab
2 ab b

output:

0 1
-1 0

result:

ok 2 lines

Test #12:

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

input:

20
1 cdfijknoqt
1 acdfghijknopqrst
1 dfjkot
19 a b c e f g h i j k l m n o p q r s t
1 abcdfghijklnopqrst
1 djo
1 acdfhijknopqrst
1 acdfijknoqt
1 cdfjkot
1 d
1 dfjo
1 abcdfghijknopqrst
1 abcdefghijklnopqrst
1 cdfijkoqt
1 dj
1 acdfhijknoqst
1 cdfijkot
1 acdfhijknopqst
1 acdfhijknoqt
1 dfjko

output:

0 11 10 10 11 10 11 11 10 10 10 11 11 10 10 11 10 11 11 10
16 0 16 16 17 16 16 16 16 16 16 17 17 16 16 16 16 16 16 16
7 7 0 6 7 6 7 7 7 6 6 7 7 7 6 7 7 7 7 6
1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
18 18 18 18 0 18 18 18 18 18 18 18 19 18 18 18 18 18 18 18
4 4 4 3 4 0 4 4 4 3 4 4 4 4 3 4 4 4 4 4
15 ...

result:

ok 20 lines

Test #13:

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

input:

1
1 a

output:

0

result:

ok single line: '0'

Test #14:

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

input:

20
19 bcfghjlmnopqrst cdiklpqt bdefhijklmnopqrst behinp cefhjlmn g dfhko ghijklpqt cdfij bcdefjklnop bcdeghijklmnopqrst bcdefghijklmnopqrst bdefgikmnopqrst cefghjklnopqrst cfjkmopst dfghnq r cdefghiklmnoprst begijmnopqrst
19 a acdfhiklmopqst demo ep acdefhijlmnqt ago adefghikmopqrs aghijklpqrt acdef...

output:

0 3 5 4 5 5 1 5 5 5 4 5 3 2 4 5 5 1 5 2
1 0 6 4 2 4 2 4 5 4 5 3 4 3 3 5 5 2 4 3
5 4 0 3 3 1 5 3 3 2 3 3 2 5 3 2 3 5 3 5
2 4 4 0 4 5 3 1 3 1 2 2 5 4 4 3 1 3 1 4
4 4 5 2 0 3 3 3 5 3 4 4 4 3 1 4 3 4 2 3
6 5 5 6 5 0 6 2 4 3 4 4 6 5 5 4 2 4 5 6
3 2 4 5 4 5 0 5 5 5 5 5 4 3 3 4 4 2 4 1
5 5 6 5 3 5 5 0 5 4 ...

result:

ok 20 lines

Test #15:

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

input:

4
8 a b ab c abd abcd abc d
11 a b abcd bcd ac bc abc d ad bd cd
10 acd b ab bcd ac bc abc d ad bd
13 a b ab c ac bc abc d ad bcd abd cd acd

output:

0 1 1 1
1 0 2 1
2 1 0 1
1 1 1 0

result:

ok 4 lines

Test #16:

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

input:

25
1 y
1 y
1 ab
1 y
1 y
1 de
1 cf
1 y
1 y
1 hi
1 y
1 y
1 kl
1 jm
1 gn
1 y
1 y
1 pq
1 y
1 y
1 st
1 ru
1 mv
1 ow
24 a b c d e f g h i j k l m n o p q r s t u v w x

output:

0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1
2 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1
3 3 0 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2
2 2 2 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1
2 2 2 2 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1
3 3 3 3 3 0 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2
...

result:

ok 25 lines

Test #17:

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

input:

4
14 a b ab c ac bc abc abcd ad bd abd cd acd bcd
9 a acd cd abcd bcd bc abc d bd
12 acd b ab c abcd bc abc d bcd bd abd cd
7 a b ab c bcd acd abcd

output:

0 1 1 2
1 0 2 1
2 1 0 1
1 1 1 0

result:

ok 4 lines

Test #18:

score: 0
Accepted
time: 136ms
memory: 7292kb

input:

25
40000 abcdefghijklmnopqsvwx abcdefghijklmnoruxy abcdefghijklmnqstuwy abcdefghijklmnrvy abcdefghijklmopqtw abcdefghijklmopvwy abcdefghijklmorsuy abcdefghijklmpqtwxy abcdefghijklmprsuy abcdefghijklmprvw abcdefghijklmqtvwxy abcdefghijklmrvwx abcdefghijklnoqrt abcdefghijklnoqtv abcdefghijklnprvw abcd...

output:

0 11 18 9 21 24 17 10 14 6 13 4 12 15 1 19 20 23 8 3 2 5 7 22 16
14 0 7 23 10 13 6 24 3 20 2 18 1 4 15 8 9 12 22 17 16 19 21 11 5
7 18 0 16 3 6 24 17 21 13 20 11 19 22 8 1 2 5 15 10 9 12 14 4 23
16 2 9 0 12 15 8 1 5 22 4 20 3 6 17 10 11 14 24 19 18 21 23 13 7
4 15 22 13 0 3 21 14 18 10 17 8 16 19 5 ...

result:

ok 25 lines

Test #19:

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

input:

3
2 ac b
3 abc bc ab
1 ab

output:

0 1 -1
-1 0 -1
-1 2 0

result:

ok 3 lines

Test #20:

score: 0
Accepted
time: 140ms
memory: 6948kb

input:

25
999952 abcdefghijklm abcdefghijklmnopqrstuw abcdefghijklmnopqrsy abcdefghijklmnopqrtwx abcdefghijklmnopqruvwy abcdefghijklmnopqrv abcdefghijklmnopqrwx abcdefghijklmnopqstuvxy abcdefghijklmnopqstuwx abcdefghijklmnopqstuxy abcdefghijklmnopqstwxy abcdefghijklmnopqsty abcdefghijklmnopqsv abcdefghijkl...

output:

0 11 18 9 21 24 17 10 14 6 13 4 12 15 1 19 20 23 8 3 2 5 7 22 16
14 0 7 23 10 13 6 24 3 20 2 18 1 4 15 8 9 12 22 17 16 19 21 11 5
7 18 0 16 3 6 24 17 21 13 20 11 19 22 8 1 2 5 15 10 9 12 14 4 23
16 2 9 0 12 15 8 1 5 22 4 20 3 6 17 10 11 14 24 19 18 21 23 13 7
4 15 22 13 0 3 21 14 18 10 17 8 16 19 5 ...

result:

ok 25 lines

Test #21:

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

input:

4
10 cd b ab c abcd bc bcd abd ad bd
10 a b bcd c ac bc abc acd ad bd
8 cd abd ab c acd bc abc ad
4 abc bcd ac bd

output:

0 1 1 -1
1 0 1 -1
2 2 0 -1
3 3 2 0

result:

ok 4 lines

Test #22:

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

input:

25
1 a
1 b
1 c
1 d
1 e
1 f
1 g
1 h
1 i
1 j
1 k
1 l
1 m
1 n
1 o
1 p
1 q
1 r
1 s
1 t
1 u
1 v
1 w
1 x
1 y

output:

0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -...

result:

ok 25 lines

Test #23:

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

input:

10
237 a bfhij ab c ac aegi dghj d ghij fgij bcdij cd fhj bcd aefhi e bdefi bcj bdeij ce efij acehj abce defj behi acegj bhj cde aej bcde agij f af abcej abf cf acf bcf egj df adf eij bcdfi abhj acdf abcj abcdf defhj bghij cdhj bcdgj cef acef bcef abcef cfgij bdhj bdef acghj cdef bdhi bcdef eghj beh...

output:

0 3 1 1 1 1 2 2 2 3
3 0 3 3 3 3 3 2 2 3
3 4 0 2 2 3 3 3 2 3
3 3 1 0 1 3 1 2 1 2
3 3 2 2 0 2 2 2 2 3
1 3 2 2 2 0 1 2 2 2
3 2 2 1 2 2 0 1 2 1
2 2 3 3 2 1 2 0 1 3
3 3 3 2 3 2 3 1 0 3
2 1 3 2 2 2 2 1 1 0

result:

ok 10 lines

Test #24:

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

input:

25
1 bcdefghijklmnopqrstuvwxy
1 cdefghijklmnopqrstuvwxy
1 defghijklmnopqrstuvwxy
1 efghijklmnopqrstuvwxy
1 fghijklmnopqrstuvwxy
1 ghijklmnopqrstuvwxy
1 hijklmnopqrstuvwxy
1 ijklmnopqrstuvwxy
1 jklmnopqrstuvwxy
1 klmnopqrstuvwxy
1 lmnopqrstuvwxy
1 mnopqrstuvwxy
1 nopqrstuvwxy
1 opqrstuvwxy
1 pqrstuvw...

output:

0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 24
-1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 23
-1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 22
-1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 21
-1 -...

result:

ok 25 lines

Test #25:

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

input:

7
110 a b bcefg c ac bc abc d ad bd abd cd acd cdefg abcd e ae be abe ce ace bce abce de ade bde abde bdefg acde bcde abcde f af bf abf cf abefg bcf defg df adf bdf abdf cdf acdf bcdf abcdf ef aef bef abef cef acef bcef abcef def adef bdef abdef cdef acdef bcdef g ag bg abg cg acg bcg acefg dg adg b...

output:

0 1 1 1 1 1 1
2 0 1 2 2 2 1
2 2 0 1 2 1 2
1 1 1 0 2 2 1
2 1 2 2 0 1 2
1 1 2 1 1 0 1
1 2 2 2 2 1 0

result:

ok 7 lines

Test #26:

score: 0
Accepted
time: 41ms
memory: 6744kb

input:

25
56964 a abcd abcdei abcdem abcdet abcdeu abcdfi abcdfo abcdfq abcdfv abcdfy abcdgi abcdgj abcdgp abcdgw abcdgy abcdh abcdhk abcdhl abcdho abcdhp abcdhu abcdir abcdit abcdj abcdjl abcdjp abcdjr abcdjy abcdlm abcdln abcdls abcdlu abcdmt abcdmv abcdnu abcdnv abcdny abcdop abcdos abcdow abcdox abcdp ...

output:

0 1 2 1 2 2 1 2 2 2 1 2 -1 3 2 2 2 2 2 3 1 -1 2 -1 -1
2 0 2 3 2 2 3 2 1 3 2 2 -1 2 3 2 1 2 2 2 2 -1 2 -1 -1
1 1 0 1 1 2 2 2 2 3 2 2 -1 1 2 2 2 1 3 3 2 -1 1 -1 -1
1 2 2 0 2 2 2 2 2 3 2 2 -1 3 2 1 3 2 2 3 2 -1 3 -1 -1
2 3 3 2 0 2 2 2 2 3 2 2 -1 3 2 2 3 2 3 3 2 -1 3 -1 -1
2 2 2 3 2 0 3 2 3 3 2 2 -1 3 3...

result:

ok 25 lines

Test #27:

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

input:

10
206 bcj fghij ab aij ac bc abc cegi ad bdefj bghj abhij cdij cdgij befgi dgi befhi cdeij bhj ce abcfi bce abce de ade bde cgij agj acde cfhj egj f cfgh dei aehij cdgi ahij bcf bcegi abdhi bdi bdf efgij bcfhj adij bcdf abcdf cefgh aef bef acdgj ahj acef abcei abcef bci beij bdef bdgij achj abeij b...

output:

0 2 2 2 2 1 2 3 2 3
1 0 1 1 2 2 2 3 2 1
2 1 0 2 3 2 2 3 3 2
3 3 2 0 3 3 1 3 3 3
2 2 1 2 0 1 2 3 2 2
1 3 2 2 2 0 2 2 1 2
2 2 2 1 2 2 0 2 2 3
3 3 3 2 3 3 1 0 3 3
2 2 1 2 1 1 1 1 0 3
3 3 2 1 2 2 2 3 2 0

result:

ok 10 lines

Test #28:

score: 0
Accepted
time: 31ms
memory: 5708kb

input:

25
7839 abcdft abcdix abcdj abcdjq abcdjr abcdk abcdlo abcdpr abcdtw abcdwy abcejm abcelx abcemu abcenr abceo abcew abcfgk abcfgq abcfkt abcflx abcfoq abcfps abcfw abcgiu abcgju abcgkv abcgny abcgpu abcgpx abcgsw abchkr abchqw abchrt abcht abcikx abcils abcins abcipv abcjkl abcjls abcjsy abcjtx abck...

output:

0 3 2 2 2 3 2 2 3 2 2 2 3 3 2 2 3 3 3 3 2 3 3 2 2
3 0 2 1 2 1 2 2 3 3 2 2 3 2 2 2 2 3 2 2 2 2 4 2 2
3 2 0 3 2 3 3 2 3 2 2 1 3 2 1 2 2 2 2 2 2 3 3 2 3
3 2 2 0 2 2 1 1 3 2 2 2 2 2 1 2 2 2 2 1 2 2 3 2 2
2 2 1 3 0 3 3 2 3 2 2 2 2 2 2 1 1 2 1 2 2 3 3 2 2
3 2 1 3 1 0 3 2 2 2 2 2 2 2 1 2 1 3 2 1 2 2 3 2 3
...

result:

ok 25 lines

Test #29:

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

input:

7
83 a cdefg ab c ac bc abc d ad bd bcfg cd acd bcd bcdeg e ae be abe ce ace bce abce de adefg efg abde cde acde bfg abcde f af dfg abf abdeg acf bcf abcf df adf bdefg abdf cdf acdf bcdf deg ef aef cdeg adfg cef acef abefg abcef def adeg bdef acdeg bdeg acdef bcdef cefg ag bg abg cg acg abdfg abcg d...

output:

0 2 1 1 1 1 2
2 0 2 1 1 2 1
1 1 0 1 1 1 2
1 1 1 0 1 2 2
2 1 1 1 0 1 1
2 1 2 2 2 0 1
2 1 1 2 2 2 0

result:

ok 7 lines

Test #30:

score: 0
Accepted
time: 37ms
memory: 6828kb

input:

25
43364 abcdeu abcdex abcdfp abcdfx abcdg abcdgk abcdgl abcdgn abcdgr abcdgx abcdh abcdhk abcdhm abcdho abcdhr abcdhw abcdix abcdiy abcdjm abcdjp abcdkl abcdkn abcdks abcdku abcdkv abcdkw abcdls abcdlx abcdly abcdmt abcdmw abcdnr abcdos abcdov abcdoy abcdpu abcdpx abcdqs abcdry abcdty abcdu abcduv ...

output:

0 2 2 2 2 2 2 2 2 3 3 2 2 2 1 2 2 1 2 2 2 1 1 2 2
2 0 1 2 2 2 1 3 3 2 3 2 2 2 1 2 2 1 1 2 2 2 2 2 2
3 2 0 2 2 2 2 2 3 2 2 3 3 2 3 2 1 2 2 2 1 3 2 3 2
2 2 2 0 1 2 2 2 3 2 2 2 3 2 2 2 2 2 2 2 1 2 1 2 1
2 2 2 2 0 2 2 3 3 3 3 1 2 2 2 1 2 2 2 2 2 2 2 2 2
2 1 1 2 2 0 2 2 1 2 3 2 1 1 2 2 2 2 2 2 2 1 1 2 2
...

result:

ok 25 lines

Test #31:

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

input:

8
66 a egh abfh bgh ac abeg adh acdfh bdeh cefh abd abgh bdegh bdh abefh cgh ae bcfgh bdfh defh befh bce beg de cdefg acgh efh abdg bcfg bcde bdfg bdefh ceg bf abf abdh adfg adfh acg aeh acfg afgh cfgh abcgh acdf abcdh abch ef bcdeh abceh dg cef acef bcfh abcef beh adef bdef bdeg dgh cdgh bcdef bceg...

output:

0 2 2 2 2 2 3 3
2 0 1 2 2 2 2 3
2 2 0 1 2 2 1 2
1 2 2 0 1 1 2 2
1 1 1 2 0 1 2 2
1 1 1 1 1 0 1 1
1 1 2 1 1 1 0 1
3 3 3 3 3 3 3 0

result:

ok 8 lines

Test #32:

score: 0
Accepted
time: 35ms
memory: 6316kb

input:

25
20714 abcde abcdep abcder abcdgr abcdhi abcdhv abcdim abcdir abcdis abcdiw abcdjr abcdkq abcdkx abcdls abcdmt abcdmv abcdnr abcdnw abcdny abcdpw abcdrx abcdsv abcdtv abce abcefs abcegq abcegu abcehu abceiu abcejm abcejw abceks abcelx abcenv abceoy abcest abcfgw abcfit abcfjk abcfkn abcflp abcfno ...

output:

0 2 2 4 1 3 2 2 3 2 2 3 3 1 3 3 2 2 2 2 2 2 2 2 2
-1 0 2 3 3 2 1 2 2 2 1 2 2 2 2 2 2 2 2 1 1 2 2 2 2
-1 2 0 4 3 2 3 2 3 3 3 3 3 3 3 3 2 3 2 3 2 3 3 3 3
-1 2 2 0 2 2 2 1 2 1 1 2 3 2 2 2 2 2 1 1 2 2 2 2 3
-1 2 2 3 0 2 2 2 3 2 2 2 2 1 2 2 1 2 2 2 1 2 2 3 1
-1 2 3 4 3 0 2 2 3 3 2 3 3 3 2 3 1 2 1 1 2 2 2...

result:

ok 25 lines

Test #33:

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

input:

6
59 a abcdef ab c ac bc abc d ad bd abd cd acd bcd abcd e ae be abe ce ace acdef abce de ade bde abde bcdef acde bcde abcde f af bf abf cf acf bcf abcf df adf bdf abdf cdf acdf bcdf abcdf ef aef bef abef cdef acef bcef abcef def adef bdef abdef
47 a b ab c ac bc abc d ad bd abd cd def bcd bcef e bd...

output:

0 2 1 1 1 1
1 0 1 1 1 1
1 1 0 2 2 2
1 1 1 0 1 1
1 1 1 1 0 1
1 1 2 2 2 0

result:

ok 6 lines

Test #34:

score: 0
Accepted
time: 33ms
memory: 6032kb

input:

25
18964 ab abcd abcden abcdfs abcdgl abcdgn abcdgx abcdgy abcdhl abcdht abcdi abcdis abcdj abcdjp abcdjx abcdku abcdkv abcdlq abcdlw abcdlx abcdru abcdrw abcdtu abcduy abcdvx abcefn abcefo abcefq abcegk abceho abcehq abcein abceis abcekm abcekw abcenr abceoq abceou abcep abcepv abceqt abcesv abcesw...

output:

0 2 3 2 2 2 2 3 3 3 3 2 2 2 3 3 2 2 3 3 2 2 3 3 2
2 0 2 1 1 1 2 1 2 2 2 2 2 2 3 3 2 1 2 2 2 2 2 1 2
2 2 0 2 2 1 1 1 2 2 2 2 2 1 3 2 2 2 2 2 1 1 2 2 1
3 3 2 0 3 2 2 2 3 3 3 2 3 3 3 3 3 2 2 2 2 2 3 3 1
3 2 3 2 0 3 2 3 2 3 3 3 3 2 3 3 3 1 2 2 2 2 3 3 2
3 2 2 2 1 0 2 1 2 1 2 2 1 1 2 3 3 2 1 3 2 2 2 2 1
...

result:

ok 25 lines

Test #35:

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

input:

7
45 abcdf b ab adfg abcef cdg abc defg ad bd cdfg bcg acef bcd abdef acdef abefg be abe cfg ace bce afg cefg acdefg bde abeg bcdefg dfg bcde bcfg efg af acg abf abcdef acf bcf acdfg df abcefg bfg beg ceg abdfg
43 abcdg cg ab c bdfg acef abc d bcdefg abcdefg bdefg dfg acd bcd g e beg bcdg abe acdeg ...

output:

0 1 2 2 2 2 2
2 0 1 1 1 2 1
1 2 0 1 2 2 1
2 2 3 0 3 1 3
2 1 2 2 0 1 2
2 1 2 2 2 0 2
1 1 1 1 1 1 0

result:

ok 7 lines

Test #36:

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

input:

22
3156 abcdh abcdi abcdil abcdmt abcdru abcdv abcegt abcers abcfj abcfrs abcfru abcgjm abcgkl abcglu abcguv abchkr abcijm abcijp abcilo abcilq abcimu abcjmv abclmo abclmv abcmno abcnoq abcnru abcopt abcpu abdefn abdeis abdelt abdenv abdes abdfjk abdfns abdfsu abdghm abdgi abdgkl abdgmt abdgr abdgrs...

output:

0 -1 3 3 -1 -1 -1 -1 4 4 -1 3 3 2 4 3 3 3 3 4 -1 -1
1 0 3 3 -1 -1 -1 -1 4 3 -1 4 3 3 3 3 3 1 3 4 -1 -1
1 -1 0 1 -1 -1 -1 -1 4 3 -1 3 2 3 3 1 3 3 2 3 -1 -1
2 -1 2 0 -1 -1 -1 -1 4 3 -1 4 3 4 4 2 2 3 3 3 -1 -1
3 -1 3 3 0 -1 -1 -1 4 3 -1 4 3 4 4 3 3 3 3 2 -1 -1
3 -1 2 3 -1 0 -1 -1 4 2 -1 4 4 4 1 3 3 3 3...

result:

ok 22 lines

Test #37:

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

input:

6
27 a b abf adef ac abcde def bcde ad acdef abd acdf bdef bcd acde e abdef be bf cde ace bce abce de ade bcdef abde
54 a b ab c ac bc abc d ad bd abd cd abcef abcdef abcd e bcdef be abe ce ace bce abce de ade bde abde cde acde bcde abcde cdef af bf abf adef acf bcf abdef df adf bdf abdf cdf acdf bc...

output:

0 1 2 2 1 3
1 0 1 1 1 2
1 2 0 2 1 1
1 2 1 0 2 2
2 2 2 1 0 3
1 2 2 1 2 0

result:

ok 6 lines

Test #38:

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

input:

25
13492 abcd abcdef abcdhs abcdht abcdhy abcdip abcdix abcdjk abcdlt abcdm abcdnq abcdor abcdou abcdpt abcdrs abcdru abcefw abcegv abceij abceik abceip abcejy abcelt abcem abcemo abcer abceru abcfhm abcfht abcfjt abcfkq abcghu abcgpy abcgsw abcgsx abcgxy abchko abchkp abchls abchqt abchrv abchsw ab...

output:

0 3 3 1 3 2 -1 2 3 3 -1 2 -1 -1 -1 -1 3 -1 2 4 -1 4 2 2 1
3 0 3 1 4 3 -1 2 2 4 -1 3 -1 -1 -1 -1 3 -1 1 4 -1 4 3 2 4
2 3 0 2 4 3 -1 2 2 4 -1 2 -1 -1 -1 -1 1 -1 2 1 -1 1 3 3 2
2 3 4 0 4 4 -1 1 3 4 -1 3 -1 -1 -1 -1 3 -1 3 4 -1 5 3 1 3
2 3 4 3 0 3 -1 2 3 4 -1 2 -1 -1 -1 -1 1 -1 2 4 -1 5 3 3 3
3 3 5 2 4 ...

result:

ok 25 lines

Test #39:

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

input:

6
44 a b ab c ac bc abcdf d ad bd abd cd acd bcd abcd e bcef be abe acef def bce abdef bef ade bde abde cde acde ef bdef f abcdef bf abf cf adef bcf abcf df adf bcdef bcdf acdf
17 a b acdf abdf ac bc bde d abcde bcde f ef af abce abcd abef abde
5 abcdef e ade def bcde
25 abcdef bcdf ab c ac adef abc...

output:

0 1 1 1 1 1
1 0 2 1 2 1
2 3 0 3 1 3
2 2 1 0 2 1
1 2 2 2 0 2
1 2 1 1 1 0

result:

ok 6 lines

Test #40:

score: 0
Accepted
time: 4ms
memory: 4280kb

input:

22
3338 abcdgl abcdgr abcdjq abcdno abcdnq abcdnv abcdps abcdrt abceht abcfg abcfi abcfkq abcfl abcghn abcghp abcglq abcgpu abcgqs abchio abcilm abcins abcit abcjnq abcjps abckop abckou abckpu abclot abcmu abcnos abcopv abcors abcosv abcouv abcqru abdef abdego abdetv abdfgs abdfnr abdfnv abdg abdghq...

output:

0 3 -1 -1 2 2 3 2 3 4 4 1 -1 1 -1 3 -1 -1 2 2 3 -1
2 0 -1 -1 3 1 3 1 3 4 4 2 -1 3 -1 4 -1 -1 3 3 3 -1
2 3 0 -1 2 3 4 1 3 4 4 3 -1 2 -1 3 -1 -1 4 2 3 -1
2 3 -1 0 2 3 3 1 2 2 3 3 -1 1 -1 3 -1 -1 4 2 3 -1
1 4 -1 -1 0 2 3 2 3 3 3 2 -1 2 -1 4 -1 -1 3 3 2 -1
3 4 -1 -1 3 0 3 2 3 4 3 3 -1 3 -1 4 -1 -1 3 3 3...

result:

ok 22 lines

Test #41:

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

input:

9
80 aceh bcdfgi ab aei ac abcdfgi abc acdefghi bdfgh bdfhi bdehi cdefghi afghi cdehi bcefi adeghi abdfghi acdefgh defi bfg fhi cdgi abce acdei ade abdefgi abcdeh cde ei bcde abcde adefi bdh abefg dgh bdfgi adfghi bcdhi abdefgh ach adf acdfh afgi bcdefg abcefi abcefhi abcdefg abcdi adefghi degi bcfi...

output:

0 2 2 -1 2 2 3 2 1
3 0 2 -1 3 2 1 2 2
5 4 0 -1 3 1 3 3 3
1 2 1 0 2 1 1 2 1
4 3 3 -1 0 2 1 2 2
4 3 2 -1 2 0 2 2 2
3 2 2 -1 2 2 0 1 1
2 1 1 -1 3 1 2 0 2
2 1 1 -1 1 1 2 1 0

result:

ok 9 lines

Test #42:

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

input:

25
8116 a abcdek abcdep abcdgj abcdjy abcdkl abcdnp abcduw abcefm abcenv abceow abcepw abcewx abcf abcfjv abcflq abcfnv abcfo abcfot abcfqw abcfv abcgho abcgkm abcgko abcgku abcgsv abchot abchqu abchsw abciju abciku abcimp abcims abcimu abcinx abciov abciox abcipr abcipy abciuw abciwx abcjot abcjov ...

output:

0 4 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 4 -1 3 -1 -1 -1 -1 3 -1 -1 -1 -1 4
-1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 3 -1 1 -1 -1 -1 -1 2 -1 -1 -1 -1 4
-1 4 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 5 -1 4 -1 -1 -1 -1 3 -1 -1 -1 -1 4
-1 4 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 2 -1 3 1 -1 -1 -1 2 -1 -1 -1 -1 3
-1 3 -1 -1 0 -1 -1 -1 -1...

result:

ok 25 lines

Test #43:

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

input:

12
120 afgil abckl abhij efhjl abjkl fjk aceil ejl bdeik adfgh hik cd abcek adeh fjl bdfhl adfgj bj adhjk ceijk hjl bhijl cfhl bdij acghj bcfil dghkl bgkl adfhk acdk cghi gkl ehkl ghijl acijl bcdgl abdjl bdfk abcf degij bdejl bdf chjkl adgl bdikl agil beghl bdej cfgj defhi bdgik bdgij bfhjl dej abdh...

output:

0 3 -1 3 -1 3 -1 -1 2 -1 -1 2
-1 0 -1 3 -1 4 -1 -1 2 -1 -1 3
-1 2 0 2 -1 2 -1 -1 1 -1 -1 1
-1 3 -1 0 -1 4 -1 -1 3 -1 -1 3
-1 4 -1 2 0 3 -1 -1 3 -1 -1 3
-1 2 -1 2 -1 0 -1 -1 1 -1 -1 3
-1 3 -1 3 -1 2 0 -1 3 -1 -1 1
-1 2 -1 1 -1 3 -1 0 1 -1 -1 2
-1 1 -1 1 -1 2 -1 -1 0 -1 -1 2
-1 3 -1 2 -1 3 -1 -1 2 0 -...

result:

ok 12 lines

Test #44:

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

input:

24
1887 abcdkt abcegi abcfgh abcfnt abcgkp abcgns abchks abchsx abcinq abcjko abcjrv abcmqr abcopq abdehr abdejs abdfjm abdfkq abdgnq abdgow abdgtx abdhox abdikp abdjt abdopu abdoqu abdovx abdqwx abefou abegix abegs abeh abehrs abeimr abeipx abeitw abejot abeknu abekvx abelqv abeltx abenpq abeosv ab...

output:

0 -1 4 4 4 -1 3 4 3 -1 5 3 -1 3 -1 3 -1 5 2 -1 -1 3 -1 3
-1 0 1 3 3 -1 4 2 1 -1 1 2 -1 3 -1 2 -1 3 3 -1 -1 2 -1 1
-1 -1 0 2 4 -1 3 1 3 -1 4 2 -1 3 -1 2 -1 2 3 -1 -1 1 -1 3
-1 -1 4 0 2 -1 4 2 2 -1 4 2 -1 1 -1 1 -1 4 1 -1 -1 2 -1 3
-1 -1 4 4 0 -1 3 4 1 -1 5 2 -1 1 -1 2 -1 5 2 -1 -1 3 -1 3
-1 -1 2 4 3 ...

result:

ok 24 lines

Test #45:

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

input:

11
105 cfgjk aeh abfgk dgh ac bcehk bfk dgjk cdhi cdgik abd dfghj bfj ahjk dghij e abcgk ghk cdghk acjk dgik acfhk ik dij abfj bcfhi bfghj aehi acegk acfgk afhij f dh bfik deh cf abfgi bdehi bcehi befi acegj bdhik cfhi efgi adfh adh eghij bgij aegh bcdk fghi acgik bdek cefg cdfk fgijk adghj abcgh cf...

output:

0 3 3 -1 1 1 2 1 -1 -1 2
2 0 1 -1 1 2 2 1 -1 -1 2
3 3 0 -1 2 2 1 2 -1 -1 3
2 3 2 0 2 2 3 1 -1 -1 2
1 3 3 -1 0 1 2 2 -1 -1 3
2 2 2 -1 2 0 1 2 -1 -1 3
2 2 2 -1 1 2 0 1 -1 -1 2
3 3 3 -1 2 3 3 0 -1 -1 1
3 3 3 -1 2 2 3 2 0 -1 3
1 1 1 -1 2 1 2 2 -1 0 3
2 2 2 -1 2 2 2 2 -1 -1 0

result:

ok 11 lines

Test #46:

score: 0
Accepted
time: 32ms
memory: 6416kb

input:

16
57190 a b ab fgiklmnop ac bc abc d ad bd abd cd acd bcd abcd abcfhjlmnop ae be abe ce ace bce abce de ade bde abde cde acde bcde abcde f af bf abf cf acf bcf abcf df adf bdf abdf cdf acdf bcdf abcdf ef bfjnop bef abef cef acef bcef acdegklmnop acfghknop adef bdef abdef cdef acdef bcdef abcdef g a...

output:

0 1 2 1 2 1 1 1 1 1 1 1 1 1 1 1
1 0 1 1 2 1 1 1 1 1 1 2 1 2 2 1
1 1 0 1 1 1 1 1 1 1 2 1 2 1 1 2
1 1 1 0 1 2 1 2 1 1 2 1 1 1 1 1
1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 0 1 2 2 2 1 1 2 1 2 1
1 1 2 2 2 2 0 1 1 2 2 1 1 2 1 2
2 1 1 1 2 2 1 0 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 0 1 2 1 1 1 1 1
1 1 1 1 1 1 ...

result:

ok 16 lines

Test #47:

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

input:

14
966 a acghikl acehikn bdfhjkn abcdefkn abcdijkl abcgjk acgijklm bcehjl adfghikmn acdehm begimn abcehkln cdehijm abcd cghiln acdefhkmn bdijmn acdfhjm ce cgilmn aegim dgln cdfghijln acgijkln bcdhkmn cdfhijkmn abcfhmn cdehijkn abegjklm dgik bdfijm efgkln abijn ehijl cflmn abcefgil cegkmn abcdghijl a...

output:

0 -1 -1 -1 4 4 4 1 3 -1 4 -1 4 -1
-1 0 -1 -1 3 4 2 3 1 -1 3 -1 4 -1
-1 -1 0 -1 3 3 3 3 2 -1 3 -1 4 -1
-1 -1 -1 0 4 4 4 3 3 -1 3 -1 4 -1
-1 -1 -1 -1 0 1 3 4 2 -1 2 -1 2 -1
-1 -1 -1 -1 2 0 2 3 1 -1 1 -1 1 -1
-1 -1 -1 -1 3 3 0 3 3 -1 3 -1 4 -1
-1 -1 -1 -1 4 3 3 0 2 -1 3 -1 4 -1
-1 -1 -1 -1 2 3 1 3 0 -1...

result:

ok 14 lines

Test #48:

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

input:

15
7865 cdeijlmno bceghjkmno abdgikln c ac bcdefhjmn abceghijo abdfjlmn bcdefmo bcdghino abd bdegikmno acd abjkn abcdefjklo abefghjlno dmno abcghijkn abe cefimn bcefgjkmo bce abce cfjklmno acfghijkmno gijln acejn cde acde acdefijlno aejkln bcdhln af abhijkmno adehilno abehjn efhijkmn bcfghjn aegjlno...

output:

0 2 1 2 2 2 2 2 1 2 2 2 2 2 2
2 0 2 2 1 2 2 1 2 2 1 2 2 2 2
2 1 0 2 1 2 2 2 2 2 1 2 2 2 2
2 2 1 0 1 1 1 1 1 1 1 1 1 1 1
2 1 1 1 0 2 2 2 1 2 1 1 1 1 1
1 1 1 1 1 0 1 1 1 1 1 1 1 1 1
2 1 2 1 2 2 0 2 1 2 2 2 2 2 2
1 1 1 1 1 1 1 0 1 1 1 1 2 1 2
2 1 1 1 2 2 2 1 0 2 1 2 1 2 1
2 2 2 1 2 2 2 2 1 0 2 1 1 2 2
...

result:

ok 15 lines

Test #49:

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

input:

14
226 bdjlm cfhmn cdimn agklm beijk bgjl bcgik bdgim abjm fil abd bcehk aehjn fhkn aehjk abgjl bghjn cfjmn aghlm dfln dhjln cdfim bdfkn degil egln bhmn cej behm ehij dfhln acjkn ahjn deiln bdijm abf fhln eijm befhl cmn bciln aefjm abel abehi bcdfn dhin gijkm behk adfhk hil adegm abef fjklm lmn bdef...

output:

0 -1 4 -1 4 -1 -1 -1 3 -1 4 -1 5 4
-1 0 2 -1 4 -1 -1 -1 4 -1 4 -1 5 4
-1 -1 0 -1 4 -1 -1 -1 3 -1 4 -1 4 4
-1 -1 3 0 4 -1 -1 -1 3 -1 4 -1 5 4
-1 -1 3 -1 0 -1 -1 -1 1 -1 3 -1 4 2
-1 -1 3 -1 3 0 -1 -1 2 -1 3 -1 4 3
-1 -1 3 -1 4 -1 0 -1 1 -1 3 -1 2 2
-1 -1 1 -1 4 -1 -1 0 4 -1 4 -1 4 3
-1 -1 2 -1 3 -1 -1...

result:

ok 14 lines

Test #50:

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

input:

15
942 djno bcdefghijlno ab acdfgimn ijklm ijo abhlm acdefiln adghijno acgijm efgijkln abehikmo dfhimn abcdefghno adfghklmno abfghjmn abefgho cdeghkno afijn abcfijo ejkln abcefgijkl dghjkl ahmn fgjm abcefko abdfgl aejklm bfgijln acdefjklo acdeghjkmn abcdfhik abfhm acefghjmo abdefghijlm bchjkl bcfikm...

output:

0 4 -1 -1 -1 4 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 0 -1 -1 -1 3 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 6 0 -1 -1 4 -1 -1 -1 -1 1 -1 -1 -1 -1
-1 1 -1 0 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 2 -1 -1 0 4 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 4 -1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 5 -1 -1 -1 3 0 -1 -1 -1 -1 -1 2 -1 -1
-1 5 -...

result:

ok 15 lines

Test #51:

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

input:

15
937 acdefhijkm abcijklo abchkn dko acdefgjklo acdefijkmo abcdfgko dghijko befgiklmo abcgil bcdefhkl befhijkln bfjno bcefijkmno adhjkm bfgjlno cdghjklm cefghjlmno acdfghjlmn en ghijln defghjmno abiklo aceiklm beijklmno eijlmno acefikl bcefhmn cdegjklm bcdghijkl cdegl acdehijkl adeil abcefhil abcdg...

output:

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

result:

ok 15 lines

Test #52:

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

input:

15
221 cikln abgik abcel gjm bcdel efhjo aijo adikl cfklo adej clo bciln cehi ijno abin efiln io agil cgilo abcil chlmo bfijn bcgjk bcdei befgj abhik aejkm dfl aflmo bcde dehjo cfkmo fhikl aekno abgi acno efikm cfgo aehkl df dekl begjo dikn efgjl bcgn dghkl acklo ajko efjlm adi aehio cgjkl abfk achj...

output:

0 -1 -1 -1 -1 -1 -1 -1 -1 -1 6 -1 -1 -1 -1
-1 0 -1 -1 -1 -1 -1 -1 -1 -1 6 -1 -1 -1 -1
-1 -1 0 -1 -1 -1 -1 -1 -1 -1 5 -1 -1 -1 -1
-1 -1 -1 0 -1 -1 -1 -1 -1 -1 6 -1 -1 -1 -1
-1 -1 -1 -1 0 -1 -1 -1 -1 -1 4 -1 -1 -1 -1
-1 -1 -1 -1 -1 0 -1 1 -1 -1 2 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 0 -1 -1 -1 6 -1 -1 -1 -1
...

result:

ok 15 lines