問題一覧 > 通常問題

No.1307 Rotate and Accumulate

レベル : / AI推定難易度 : 1625 / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 103
作問者 : stoq / テスター : keymoon
お気に入りにしたユーザー ProblemId : 4366 / 自分の提出
問題文最終更新日: 2023-02-28 17:49:44
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
Advent Calendar Contest 2020 (順位表) の他の問題:

Problem Statement

There are 0-indexed sequences $A= (a_i), \ B=(b_i)$ of length $N$. Initially, all elements of $B$ are $0$.

Perform the following operation $Q$ times.

  • In the $j$-th operation, for each $i = 0,1,\dots,N-1$, add $a_{i+r_j \ {\rm mod} \ N}$ to $b_i$.
    Here, $X \ {\rm mod} \ M$ denotes the remainder when $X$ is divided by $M$.

For example, if $A = (1,2,3), \ B = (0,0,0), \ r_j = 1$, performing the operation results in $B = (2,3,1)$.

Find $B$ after the $Q$ operations.

Input

$N \ Q$
$a_0 \ a_1 \ \dots a_{N-1}$
$r_1 \ r_2 \ \dots r_Q$

  • All inputs are integers.
  • $1 \leq N \leq 10^5$
  • $1 \leq Q \leq 2 \times 10^5$
  • $0 \leq a_i \leq 10^3$
  • $0 \leq r_i \leq N-1$

Output

Print $B$ after the operations, separated by spaces.

Sample

Sample 1
Input
3 2
0 1 2
0 1
Output
1 3 2

In the 1st operation, $0, 1, 2$ are added to $b_0, b_1, b_2$ respectively, and in the 2nd operation, $1, 2, 0$ are added to $b_0, b_1, b_2$ respectively.

Sample 2
Input
5 5
2 7 1 8 2
0 1 2 3 4
Output
20 20 20 20 20

Sample 3
Input
7 9
1 1 2 3 5 8 13
1 4 1 4 2 1 3 5 6
Output
39 44 50 41 45 53 25

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