問題一覧 > 通常問題

No.1020 Reverse

レベル : / AI推定難易度 : 950 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 345
作問者 : chocorusk / テスター : leafirby
お気に入りにしたユーザー ProblemId : 4005 / 自分の提出
問題文最終更新日: 2020-03-18 02:40: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 243 (順位表) の他の問題:

Problem Statement

You are given a string $S$ of length $N$. Find the string obtained by performing the following operation in the order $i=1, 2, \ldots , N-K+1$.

  • Reverse the part of $S$ from the $i$-th character to the $i+K-1$-th character.

Input

$N\ K$
$S$

  • $2\leq K\leq N\leq 2\times 10^5$
  • $N$ and $K$ are integers.
  • $S$ is a string of length $N$ consisting of lowercase English letters.

Output

Output the string resulting from performing the operations on $S$.

Sample

Sample 1
Input
4 3
myon
Output
onmy

  • First, reverse the $1$-st through $3$-rd characters of $S$. $S$ then becomes oymn.
  • Next, reverse the $2$-nd through $4$-th characters of $S$. $S$ then becomes onmy.

Sample 2
Input
9 4
ababababa
Output
bababaaba

Sample 3
Input
2 2
ac
Output
ca

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