CF615C.Running Track

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A boy named Ayrat lives on planet AMI-1511. Each inhabitant of this planet has a talent. Specifically, Ayrat loves running, moreover, just running is not enough for him. He is dreaming of making running a real art.

First, he wants to construct the running track with coating t. On planet AMI-1511 the coating of the track is the sequence of colored blocks, where each block is denoted as the small English letter. Therefore, every coating can be treated as a string.

Unfortunately, blocks aren't freely sold to non-business customers, but Ayrat found an infinite number of coatings s. Also, he has scissors and glue. Ayrat is going to buy some coatings s, then cut out from each of them exactly one continuous piece (substring) and glue it to the end of his track coating. Moreover, he may choose to flip this block before glueing it. Ayrat want's to know the minimum number of coating s he needs to buy in order to get the coating t for his running track. Of course, he also want's to know some way to achieve the answer.

一名名叫阿亚特的男孩生活在 AMI-1511 星球上。该星球上的每位居民都拥有一种天赋。具体而言,阿亚特酷爱跑步;但仅仅跑步还远远不能满足他——他梦想将跑步升华为一门真正的艺术。

首先,他想建造一条具有涂层 tt 的跑道。在 AMI-1511 星球上,跑道的涂层由一串彩色方块构成,每个方块用一个小写英文字母表示。因此,每种涂层均可视为一个字符串。

不幸的是,这些方块并不向非商业客户自由出售;但阿亚特找到了无限多份涂层 ss。此外,他还拥有剪刀和胶水。阿亚特计划购买若干份涂层 ss,然后从每份中恰好裁剪出一段连续子串,并将该子串粘贴至其跑道涂层的末尾。而且,在粘贴前,他可以选择将该子串翻转(即取其逆序)。阿亚特想知道:为获得目标涂层 tt,他至少需要购买多少份涂层 ss?当然,他也希望知道一种达成该最小值的具体方案。

输入格式

First line of the input contains the string s — the coating that is present in the shop. Second line contains the string t — the coating Ayrat wants to obtain. Both strings are non-empty, consist of only small English letters and their length doesn't exceed 2100.

输入的第一行包含字符串 ss —— 商店中现有的涂层。
第二行包含字符串 tt —— Ayrat 想要获得的涂层。
两个字符串均非空,仅由小写英文字母组成,且长度均不超过 2100。

输出格式

The first line should contain the minimum needed number of coatings n or -1 if it's impossible to create the desired coating.

If the answer is not -1, then the following n lines should contain two integers x__i and y__i — numbers of ending blocks in the corresponding piece. If x__i ≤ y__i then this piece is used in the regular order, and if x__i > y__i piece is used in the reversed order. Print the pieces in the order they should be glued to get the string t.

第一行应输出所需的最少涂层数 $ n $,如果无法构造出目标涂层,则输出 −1-1。

若答案不为 −1-1,则接下来的 $ n $ 行每行应包含两个整数 $ x_i $ 和 $ y_i $ —— 分别表示对应片段的起始块编号和结束块编号。若 $ x_i \leq y_i $,则该片段按原始顺序使用;若 $ x_i > y_i $,则该片段按逆序使用。请按将这些片段粘贴以得到字符串 $ t $ 的顺序输出各片段。

输入输出样例

  • 输入#1

    abc
    cbaabc

    输出#1

    2
    3 1
    1 3
  • 输入#2

    aaabrytaaa
    ayrat

    输出#2

    3
    1 1
    6 5
    8 7
  • 输入#3

    ami
    no

    输出#3

    -1

说明/提示

In the first sample string "cbaabc" = "cba" + "abc".

In the second sample: "ayrat" = "a" + "yr" + "at".

在第一个样例字符串中,“cbaabc” = “cba” + “abc”。

在第二个样例中,“ayrat” = “a” + “yr” + “at”。

输入解题思路,AI测评打分。不知道怎么写?

首页