Logo
(追記) (追記ここまで)

5987번 - String Function Encoding 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB23821319689.498%

문제

Bessie discovered a new function that the entire herd can apply to its character strings.

Given both a number N (1 <= N <= 15) and a string S, with length strictly greater than N, define f(N, S) as a new string composed of the concatenation of the substring from character N (zero based -- first character is number 0) through the end of S and the string S itself.

For example, with N = 2, and S = "COW", f(N, S) = "W" + "COW" = "WCOW". Also, f(3, "USACO") = "CO" + "USACO" = "COUSACO".

Bessie is enthralled with this function and wants to iterate it several times. For example, if she iterates the function once for "COW" and N = 2, she will get "WCOW". If she applies the function with N = 2 again to that string, she will get "OWWCOW", and if she applies it one more time with N = 2, she will get "WCOWOWWCOW".

Help Bessie encode a total of Z (1 <= Z <= 100) strings, str_1, str_2, and so on. Each str_i has length in the range 2..100 and contains only upper case letters. Each string is presented with its own N_i (0 <= N_i < length(str_i), and iteration count C_i (1 <= C_i <= 12).

입력

  • Line 1: A single integer: Z
  • Lines 2..Z+1: Line i+1 contains two space-separated integers, a space, and string to be encoded: N_i, C_i, and str_i

출력

  • Lines 1..Q: Line j contains the iterated, encoded version of str_j

제한

예제 입력 1

2
2 3 COW
3 2 USACO

예제 출력 1

WCOWOWWCOW
SACOCOUSACO

힌트

The arrow denotes an iteration of the function

  • COW -> WCOW -> OWWCOW -> WCOWOWWCOW
  • USACO -> COUSACO -> SACOCOUSACO

출처

Olympiad > USA Computing Olympiad > 2010-2011 Season > USACO US Open 2011 Contest > Bronze 4번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /