QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#21230. 字符串函数编码

Statistics

Bessie 发现了可让整个牛群用于字符串的新函数。

给定 $N$($1\le N\le15$)及长度严格大于 $N$ 的字符串 $S$,定义 $f(N,S)$:把从字符 $N$(从 0 编号,第一个字符是 0)到 $S$ 末尾的子串,与 $S$ 本身依次连接。

例如 $N=2$、$S=$ COW,$f(N,S)=$ W + COW = WCOW。另有 $f(3,\text{USACO})=$ CO + USACO = COUSACO。

她着迷于此函数,希望多次迭代。COW 在 $N=2$ 下迭代一次得到 WCOW,再用 $N=2$ 得 OWWCOW,第三次同样用 $N=2$ 得 WCOWOWWCOW。

请编码 $Z$ 个字符串($1\le Z\le100$),$str_1,str_2,\ldots$。各长 $2..100$,仅含大写字母。各自带 $N_i$($0\le N_i<\operatorname{length}(str_i)$)和迭代次数 $C_i$($1\le C_i\le12$)。

输入格式

  • 第 1 行:整数 $Z$。
  • 第 $2..Z+1$ 行:第 $i+1$ 行为两个空格分隔的整数,再一个空格和字符串,依次是 $N_i,C_i,str_i$。

输出格式

  • 第 $1,\ldots,Q$ 行:第 $j$ 行为 $str_j$ 迭代编码后的版本。

样例

输入格式 1

2
2 3 COW
3 2 USACO

输出格式 1

WCOWOWWCOW
SACOCOUSACO

说明

箭头表示一次函数迭代: COW -> WCOW -> OWWCOW -> WCOWOWWCOW; USACO -> COUSACO -> SACOCOUSACO.

题目作者:Lewin Gan,2011

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.