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

23644번 - String Product 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 (추가 시간 없음) 256 MB722100.000%

문제

Let $f(c)$ be the 0ドル$-based alphabetic number of a small English letter $c,ドル hence $f(a) = 0,ドル $f(b) = 1,ドル $\ldots,ドル $f(z) = 25$. The product $s \times t$ of two strings $s = s_0 \ldots s_{n - 1}$ and $t = t_0 \ldots t_{m - 1}$ is a string $u = u_0 \ldots u_{nm - 1},ドル where $f(u_{j \cdot n + i}) = (f(s_i) + f(t_j)) \bmod 26$ for all $i = 0, \ldots, n - 1$ and $j = 0, \ldots, m - 1$. For example, $abc \times de = defefg,ドル $de \times abc = deeffg,ドル $xy \times yz = vwwx$.

You are given a string $s$. Find two strings $a$ and $b$ such that $a \times b = s$. If there are multiple options of $a$ and $b,ドル find the one such that the string $a + b$ (where $+$ stands for concatenation) is lexicographically smallest. If there are still several answers, find the one with the smallest length of $a$.

입력

The only line of the input contains the string $s$ of small English letters (1ドル \le |s| \le 10^6$).

출력

If it is impossible to find two strings $a, b$ such that $a \times b = s,ドル print $-1$. Otherwise, print $a$ and $b$ separated by a space. The string $a+b$ should be lexicographically smallest among all suitable pairs $(a, b)$. In case of a tie, $|a|$ should be smallest possible.

제한

예제 입력 1

ddbb

예제 출력 1

aa db

예제 입력 2

eefbbcccdddeaabaab

예제 출력 2

aab ebcdaa

힌트

출처

Contest > Open Cup > 2018/2019 Season > Stage 8: Grand Prix of Dolgoprudny F번

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

출처

대학교 대회

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

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