問題一覧 > 通常問題

No.1018 suffixsuffixsuffix

レベル : / AI推定難易度 : 2225 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 21
作問者 : maspy / テスター : beet
お気に入りにしたユーザー ProblemId : 4014 / 自分の提出
問題文最終更新日: 2022-04-25 10:42:30
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 242 (順位表) の他の問題:

Problem Statement

You are given a string $S$ of length $N$, a positive integer $M$, and a sequence $K_1,\ldots,K_Q$ of length $Q$.

Let $T$ be the string obtained by repeating the string $S$ $M$ times. When the suffixes $T_1, T_2, \ldots, T_{NM}$ of $T$ are sorted in lexicographical order, find the $K_1,\ldots,K_Q$-th suffixes.

Here, the suffix $T_i$ of $T$ is the substring of $T$ from the $i$-th character to the end.

Input

$N\ M\ Q$
$S$
$K_1\ K_2\ \ldots \ K_Q$

  • $N$ is a positive integer satisfying $1\leqq N\leqq 10^5$.
  • $M$ is a positive integer satisfying $1\leqq M\leqq 10^9$.
  • $Q$ is a positive integer satisfying $1\leqq Q\leqq \min(NM, 10^5)$.
  • $S$ is a string of length $N$ consisting of lowercase English letters.
  • $K_i$ are positive integers satisfying $1\leqq K_1 < K_2 < \cdots < K_Q \leqq NM$.

Output

For each $i$, find $n_i$ such that the $K_i$-th suffix is $T_{n_i}$, and print them separated by spaces.
Print a newline at the end.

Sample

Sample 1
Input
4 2 8
puyo
1 2 3 4 5 6 7 8
Output
8 4 5 1 6 2 7 3

$T = \text{puyopuyo}$. Sorting the suffixes in lexicographical order gives the following order.

  • $T_8 = \text{o}$
  • $T_4 = \text{opuyo}$
  • $T_5 = \text{puyo}$
  • $T_1 = \text{puyopuyo}$
  • $T_6 = \text{uyo}$
  • $T_2 = \text{uyopuyo}$
  • $T_7 = \text{yo}$
  • $T_3 = \text{yopuyo}$

Sample 2
Input
5 10 4
ahaha
10 20 30 40
Output
5 3 1 4

Sample 3
Input
5 10 4
ihihi
10 20 30 40
Output
7 4 11 8

Sample 4
Input
26 1000000000 1
abcdefghijklmnopqrstuvwxyz
26000000000
Output
26

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