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

25729번 - Double-Colored Papers 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 (추가 시간 없음) 1024 MB (추가 메모리 없음)110131140.741%

문제

In your factory, you are making two kinds of colored paper, one colored red, and the other colored blue.

Each red-colored paper has a string $S$ written on it: it is made of $|S|$ unit squares in a row, and $S_i$ is written on the $i$th square from the left.

Each blue-colored paper has a string $T$ written on it: it is made of $|T|$ unit squares in a row, and $T_i$ is written on the $i$th square from the left.

You plan to make a new kind of paper called double-colored paper out of red and blue paper. To do so, you will cut down a piece of red paper to only leave the continuous part with a positive integer length, and again with blue paper. Then, you will glue the ending part of the red paper to the starting part of the blue paper.

For example, suppose $S$ is abcde and $T$ is fghij. You can make a double-colored paper with string bcdfg or abcij written on it. However, you cannot make a double-colored paper with string acdghij or fghij written on it. (Here the underlined string denotes a part of the red paper, and the rest denotes a part of the blue paper.)

Among all possible double-colored papers that can be made, you want to know the one with the lexicographically $K$-th smallest string written on it. Note that there may be papers with the same strings written on them, but with different lengths of red paper: in this case, you may order them arbitrarily.

입력

The first line contains string $S$.

The second line contains string $T$.

The third line contains integer $K$.

출력

If the total number of possible double-colored papers is strictly less than $K,ドル output $-1$.

Otherwise, output the lexicographically $K$-th smallest string of all possible double-colored papers that can be made.

제한

  • 1ドル\le |S|\le 75,円 000$
  • 1ドル\le |T|\le 75,円 000$
  • $S$ and $T$ consists of lowercase alphabets.
  • 1ドル\le K\le 8\times 10^{18}$

예제 입력 1

tww
wtw
21

예제 출력 1

wwtw

All possible double-colored papers that can be made are tt, ttw, tw, twt, twt, twtw, twtw, tww, twwt, twwt, twwtw, twwtw, twww, twwwt, twwwtw, wt, wtw, ww, wwt, wwt, wwtw, wwtw, www, wwwt, wwwtw, in this order.

힌트

출처

University > KAIST > KAIST ICPC Mock Competition > 2022 KAIST 12th ICPC Mock Competition C번

Camp > Petrozavodsk Programming Camp > Winter 2023 > Day 4: KAIST+KOI Contest, Grand Prix of Korea E번

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

출처

대학교 대회

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

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