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$ 自身をこの順に連結します。

例:$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$ 行目は空白区切り整数 2 個、空白、文字列の順で $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.