問題一覧 > 通常問題

No.2034 Anti Lexicography

レベル : / AI推定難易度 : 147 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 236
作問者 : milkcoffee / テスター : nok0 riano
お気に入りにしたユーザー ProblemId : 8178 / 自分の提出
問題文最終更新日: 2022-07-13 16:18:20
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 356 (順位表) の他の問題:

Problem Statement

You are given a string $S$ of length $N$ consisting of lowercase English letters.
Arrange all $26^N$ strings of length $N$ consisting of lowercase English letters in lexicographical order.
Supposing that $S$ is the $k$-th string from the front in lexicographical order, output the string that is the $k$-th from the back.

Input

$N$
$S$

  • $1 \leq N \leq 2 \times 10^5$
  • $N$ is an integer.
  • $S$ is a string of length $N$ consisting of lowercase English letters.

Output

Output the answer string on $1$ line.

Sample

Sample 1
Input
3
aab
Output
zzy

Arranging the strings of length $3$ consisting of lowercase English letters in lexicographical order gives $aaa,aab,aac,\dots,zzy,zzz$.
Since $aab$ is the $2$-nd string from the front, output $zzy$, which is the $2$-nd string from the back.

Sample 2
Input
1
n
Output
m

Sample 3
Input
9
bfprxlwvi
Output
yukicoder

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。