0
点赞
收藏
分享

微信扫一扫

分享一个编程比赛的网站:https://codeforces.com/

Raow1 2022-01-14 阅读 70
开发语言

分享一个编程比赛的网站:https://codeforces.com/

网站是英文的,使用360浏览器可以翻译,但是会有文字重叠,效果不是很好。

是编程高手,练习成编程高手,可以来网站Codeforces ,网站支持大多数编程语言。

注册后,开启虚拟比赛,提交答案就好,会有人批改的。

下面是转载的一道试题。

E. Masha-forgetful

time limit per test

3 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Masha meets a new friend and learns his phone number — ss. She wants to remember it as soon as possible. The phone number — is a string of length mm that consists of digits from 00 to 99. The phone number may start with 0.

Masha already knows nn phone numbers (all numbers have the same length mm). It will be easier for her to remember a new number if the ss is represented as segments of numbers she already knows. Each such segment must be of length at least 22, otherwise there will be too many segments and Masha will get confused.

For example, Masha needs to remember the number: s=s= '12345678' and she already knows n=4n=4 numbers: '12340219', '20215601', '56782022', '12300678'. You can represent ss as a 33 segment: '1234' of number one, '56' of number two, and '78' of number three. There are other ways to represent ss.

Masha asks you for help, she asks you to break the string ss into segments of length 22 or more of the numbers she already knows. If there are several possible answers, print any of them.

Input

The first line of input data contains an integer tt (1≤t≤1041≤t≤104) —the number of test cases.

Before each test case there is a blank line. Then there is a line containing integers nn and mm (1≤n,m≤1031≤n,m≤103) —the number of phone numbers that Masha knows and the number of digits in each phone number. Then follow nn line, ii-th of which describes the ii-th number that Masha knows. The next line contains the phone number of her new friend ss.

Among the given n+1n+1 phones, there may be duplicates (identical phones).

It is guaranteed that the sum of n⋅mn⋅m (nn multiplied by mm) values over all input test cases does not exceed 106106.

Output

You need to print the answers to tt test cases. The first line of the answer should contain one number kk, corresponding to the number of segments into which you split the phone number ss. Print -1 if you cannot get such a split.

If the answer is yes, then follow kk lines containing triples of numbers l,r,il,r,i. Such triplets mean that the next r−l+1r−l+1 digits of number ss are equal to a segment (substring) with boundaries [l,r][l,r] of the phone under number ii. Both the phones and the digits in them are numbered from 11. Note that r−l+1≥2r−l+1≥2 for all kk lines.

举报

相关推荐

0 条评论