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, 한 번 더면 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.