LoginSignup
0
0

More than 3 years have passed since last update.

yukicoder No.1013 〇マス進む

Posted at

問題URL : yukicoder.me/problems/no/1013

解説

頂点 $i$ から頂点 $i+T_i$ へ辺を張ったグラフを考える。
求めるものは $k=1, 2, \dots, N$ それぞれについて、頂点 $k$ から辺に沿った移動を $K$ 回して着く頂点である。
このグラフは周期 $N$ で同じパターンが繰り返されるので、頂点 $1, 2, \dots, N$ にだけ注目すればよい。
$K$ 回移動した後の位置はダブリングで求まり、計算量は $O(N\log K)$ である。

提出コード : yukicoder.me/submissions/447245

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