CF1029A.Many Equal Substrings

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given a string tt consisting of nn lowercase Latin letters and an integer number kk.

Let's define a substring of some string ss with indices from ll to rr as s[l…r]s[l \dots r].

Your task is to construct such string ss of minimum possible length that there are exactly kk positions ii such that s[i…i+n−1]=ts[i \dots i + n - 1] = t. In other words, your task is to construct such string ss of minimum possible length that there are exactly kk substrings of ss equal to tt.

It is guaranteed that the answer is always unique.

给你一个由 nn 个小写拉丁字母组成的字符串 tt 和一个整数 kk。

我们定义字符串 ss 中从索引 ll 到 rr 的子串为 s[l…r]s[l \dots r]。

你的任务是构造一个长度尽可能小的字符串 ss,使得恰好存在 kk 个位置 ii 满足 s[i…i+n−1]=ts[i \dots i + n - 1] = t。换言之,你的任务是构造一个长度尽可能小的字符串 ss,使得 ss 中恰好有 kk 个等于 tt 的子串。

保证答案总是唯一的。

输入格式

The first line of the input contains two integers nn and kk (1≤n,k≤501 \le n, k \le 50) — the length of the string tt and the number of substrings.

The second line of the input contains the string tt consisting of exactly nn lowercase Latin letters.

输入的第一行包含两个整数 nn 和 kk(1≤n,k≤501 \le n, k \le 50)—— 分别表示字符串 tt 的长度和子串的数量。

输入的第二行包含字符串 tt,该字符串恰好由 nn 个小写拉丁字母组成。

输出格式

Print such string ss of minimum possible length that there are exactly kk substrings of ss equal to tt.

It is guaranteed that the answer is always unique.

输出满足条件的最短字符串 ss,使得 ss 中恰好有 kk 个子串等于 tt。

保证答案唯一。

输入输出样例

  • 输入#1

    3 4
    aba

    输出#1

    ababababa
  • 输入#2

    3 2
    cat

    输出#2

    catcat

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

首页