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.