#P15227. [SWERC 2017] Frosting on the Cake

[SWERC 2017] Frosting on the Cake

题目描述

Iskander the Baker is decorating a huge cake, covering the rectangular surface of the cake with frosting. For this purpose, he mixes frosting sugar with lemon juice and food coloring, in order to produce three kinds of frosting: yellow, pink, and white. These colors are identified by the numbers 0 for yellow, 1 for pink, and 2 for white.

To obtain a nice pattern, he partitions the cake surface into vertical stripes of width A1,A2,,An A_1, A_2, \ldots, A_n centimeters, and horizontal stripes of height B1,B2,,Bn B_1, B_2, \ldots, B_n centimeters, for some positive integer n n . These stripes split the cake surface into n×n n \times n rectangles. The intersection of vertical stripe i i and horizontal stripe j j has color number (i+j)mod3 (i + j) \bmod 3 for all 1i,jn 1 \leq i, j \leq n . To prepare the frosting, Iskander wants to know the total surface in square centimeters to be colored for each of the three colors, and asks for your help.

:::aligned{center} :::

输入格式

The input consists of the following integers:

  • on the first line: the integer n n ,
  • on the second line: the values of A1,,An A_1, \ldots, A_n , n n integers separated with single spaces,
  • on the third line: the values of B1,,Bn B_1, \ldots, B_n , n n integers separated with single spaces.

输出格式

The output should consist of three integers separated with single spaces, representing the total area for each color 0, 1, and 2.

3
1 1 1
1 1 1
3 3 3
7
6 2 4 5 1 1 4
2 5 1 4 2 3 4
155 131 197

提示

Limits

The input satisfies 3n100000 3 \leq n \leq 100\,000 and $1 \leq A_1, \ldots, A_n, B_1, \ldots, B_n \leq 10\,000$.