0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AtCoder Beginner Contest 337 E - Permute K times 2 のかみ砕いた説明

Last updated at Posted at 2025-04-04

1.問題

2.説明

サンプル 1 の、$P = (5,6,3,1,2,4)$ を考えてみる。まず大事なのが、どんな順列もいくつかのサイクルに分けられるということである。この順列の場合、

1 → 5 → 2 → 6 → 4 → 1 、 3 → 3

の 2 つのサイクルが存在する。これをもとに考察をしてみる。

まず、$P_{i}$ が何を表しているかというと、(当たり前だけど)$i$ の 1 つ先の行き先である。グラフ上で考えるなら、$i$ から伸びる有向辺の先と言える。

では、$P_{P_{i}}$ は何を表しているか?これは、$i$ の 1 つ先の行き先($P_{i}$)の 1 つ先の行き先($P_{P_{i}}$)、つまり $i$ の 2 つ先の行き先ということになる。

1 回操作を施すことにより、$P_{i}$ は $i$ の 2 つ先の行き先を指し示すようになる($P^2$)。よって、これに対してさらに 1 回の操作を施すと、$i$ の 2 つ先の行き先($P^2_{i}$)の 2 つ先の行き先 ( $P^2_{P^2_{i}}$)、つまり $2^2$ つ先の行き先になる。

これを $K$ 回繰り返すと、$P_{i}$ は $2^K$ 先の行き先($P^{2^K}$)となる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?