CF1335B.Construct the String

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given three positive integers nn, aa and bb. You have to construct a string ss of length nn consisting of lowercase Latin letters such that each substring of length aa has exactly bb distinct letters. It is guaranteed that the answer exists.

You have to answer tt independent test cases.

Recall that the substring s[l…r]s[l \dots r] is the string sl,sl+1,…,srs_l, s_{l+1}, \dots, s_{r} and its length is r−l+1r - l + 1. In this problem you are only interested in substrings of length aa.

给你三个正整数 nn、aa 和 bb。你需要构造一个长度为 nn 的字符串 ss,其中仅包含小写拉丁字母,使得 ss 的每个长度为 aa 的子串恰好包含 bb 个互不相同的字母。题目保证答案一定存在。

你需要回答 tt 个相互独立的测试用例。

回顾一下:子串 s[l…r]s[l \dots r] 表示字符串 sl,sl+1,…,srs_l, s_{l+1}, \dots, s_{r},其长度为 r−l+1r - l + 1。在本题中,你只需关注长度为 aa 的子串。

输入格式

The first line of the input contains one integer tt (1≤t≤20001 \le t \le 2000) — the number of test cases. Then tt test cases follow.

The only line of a test case contains three space-separated integers nn, aa and bb (1≤a≤n≤2000,1≤b≤min⁡(26,a)1 \le a \le n \le 2000, 1 \le b \le \min(26, a)), where nn is the length of the required string, aa is the length of a substring and bb is the required number of distinct letters in each substring of length aa.

It is guaranteed that the sum of nn over all test cases does not exceed 20002000 (∑n≤2000\sum n \le 2000).

输入的第一行包含一个整数 tt(1≤t≤20001 \le t \le 2000),表示测试用例的数量。随后是 tt 个测试用例。

每个测试用例仅一行,包含三个以空格分隔的整数 nn、aa 和 bb(1≤a≤n≤20001 \le a \le n \le 2000,1≤b≤min⁡(26,a)1 \le b \le \min(26, a)),其中 nn 是所要求字符串的长度,aa 是子串的长度,bb 是每个长度为 aa 的子串中所需的不同字母的数量。

保证所有测试用例的 nn 之和不超过 20002000(即 ∑n≤2000\sum n \le 2000)。

输出格式

For each test case, print the answer — such a string ss of length nn consisting of lowercase Latin letters that each substring of length aa has exactly bb distinct letters. If there are multiple valid answers, print any of them. It is guaranteed that the answer exists.

对于每个测试用例,输出一个答案——即一个长度为 nn 的字符串 ss,该字符串仅由小写拉丁字母组成,且其每个长度为 aa 的子串恰好包含 bb 个不同的字母。如果存在多个合法答案,输出任意一个即可。题目保证答案一定存在。

输入输出样例

  • 输入#1

    4
    7 5 3
    6 1 1
    6 6 1
    5 2 2

    输出#1

    tleelte
    qwerty
    vvvvvv
    abcde

说明/提示

In the first test case of the example, consider all the substrings of length 55:

  • "tleel": it contains 33 distinct (unique) letters,
  • "leelt": it contains 33 distinct (unique) letters,
  • "eelte": it contains 33 distinct (unique) letters.

在示例的第一个测试用例中,考虑所有长度为 55 的子字符串:

  • "tleel":包含 33 个互不相同的(唯一的)字母,
  • "leelt":包含 33 个互不相同的(唯一的)字母,
  • "eelte":包含 33 个互不相同的(唯一的)字母。

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

首页