CF231D.Magic Box

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

One day Vasya was going home when he saw a box lying on the road. The box can be represented as a rectangular parallelepiped. Vasya needed no time to realize that the box is special, as all its edges are parallel to the coordinate axes, one of its vertices is at point (0, 0, 0), and the opposite one is at point (_x_1, _y_1, _z_1). The six faces of the box contain some numbers _a_1, _a_2, ..., _a_6, exactly one number right in the center of each face.

The numbers are located on the box like that:

  • number _a_1 is written on the face that lies on the ZOX plane;
  • _a_2 is written on the face, parallel to the plane from the previous point;
  • _a_3 is written on the face that lies on the XOY plane;
  • _a_4 is written on the face, parallel to the plane from the previous point;
  • _a_5 is written on the face that lies on the YOZ plane;
  • _a_6 is written on the face, parallel to the plane from the previous point.

At the moment Vasya is looking at the box from point (x, y, z). Find the sum of numbers that Vasya sees. Note that all faces of the box are not transparent and Vasya can't see the numbers through the box. The picture contains transparent faces just to make it easier to perceive. You can consider that if Vasya is looking from point, lying on the plane of some face, than he can not see the number that is written on this face. It is enough to see the center of a face to see the corresponding number for Vasya. Also note that Vasya always reads correctly the a__i numbers that he sees, independently of their rotation, angle and other factors (that is, for example, if Vasya sees some a__i = 6, then he can't mistake this number for 9 and so on).

一天,瓦西娅在回家路上看到路边有一个箱子。该箱子可被表示为一个长方体(矩形平行六面体)。瓦西娅立刻意识到这个箱子很特别:它的所有棱均与坐标轴平行;其中一个顶点位于点 (0, 0, 0)(0,\,0,\,0),而与其相对的顶点则位于点 (x1, y1, z1)(x_1,\,y_1,\,z_1)。箱子的六个面上各标有一个数字 a1, a2, …, a6a_1,\,a_2,\,\dots,\,a_6,每个数字恰好位于对应面的正中心。

这些数字在箱子上的分布方式如下:

  • 数字 a1a_1 标在位于 ZOXZOX 平面上的那个面上;
  • a2a_2 标在与上一平面平行的那个面上;
  • a3a_3 标在位于 XOYXOY 平面上的那个面上;
  • a4a_4 标在与上一平面平行的那个面上;
  • a5a_5 标在位于 YOZYOZ 平面上的那个面上;
  • a6a_6 标在与上一平面平行的那个面上。

此时,瓦西娅正从点 (x, y, z)(x,\,y,\,z) 处观察该箱子。请计算瓦西娅所能看到的数字之和。注意:箱子的所有面均不透明,瓦西娅无法透过箱子看到背面的数字。图中将某些面绘制成透明状,仅为便于理解。你可以认为:若瓦西娅的观察点恰好落在某个面所在的平面上,则他无法看到该面上所标的数字。只要瓦西娅能看见某个面的中心,他就能够看到其上所标的对应数字。此外请注意:无论数字以何种旋转角度、视角或其他因素呈现,瓦西娅总能准确无误地读出他所看到的 aia_i 值(例如,若瓦西娅看到某个 ai=6a_i = 6,他绝不会将其误认为 99 等其他数字)。

输入格式

The fist input line contains three space-separated integers x, y and z (|x|, |y|, |z| ≤ 106) — the coordinates of Vasya's position in space. The second line contains three space-separated integers _x_1, _y_1, _z_1 (1 ≤ _x_1, _y_1, _z_1 ≤ 106) — the coordinates of the box's vertex that is opposite to the vertex at point (0, 0, 0). The third line contains six space-separated integers _a_1, _a_2, ..., _a_6 (1 ≤ a__i ≤ 106) — the numbers that are written on the box faces.

It is guaranteed that point (x, y, z) is located strictly outside the box.

第一行输入包含三个用空格分隔的整数 xx、yy 和 zz(∣x∣,∣y∣,∣z∣≤106|x|, |y|, |z| \leq 10^6),表示瓦西亚在三维空间中的位置坐标。
第二行输入包含三个用空格分隔的整数 x1x_1、y1y_1、z1z_1(1≤x1,y1,z1≤1061 \leq x_1, y_1, z_1 \leq 10^6),表示盒子一个顶点的坐标,该顶点与位于点 (0,0,0)(0, 0, 0) 处的顶点相对。
第三行输入包含六个用空格分隔的整数 a1,a2,…,a6a_1, a_2, \dots, a_6(1≤ai≤1061 \leq a_i \leq 10^6),表示写在盒子六个面上的数字。

保证点 (x,y,z)(x, y, z) 严格位于盒子外部。

输出格式

Print a single integer — the sum of all numbers on the box faces that Vasya sees.

输出一个整数——即瓦西娅所能看到的盒子各个面上所有数字的总和。

输入输出样例

  • 输入#1

    2 2 2
    1 1 1
    1 2 3 4 5 6

    输出#1

    12
  • 输入#2

    0 0 10
    3 2 3
    1 2 3 4 5 6

    输出#2

    4

说明/提示

The first sample corresponds to perspective, depicted on the picture. Vasya sees numbers _a_2 (on the top face that is the darkest), _a_6 (on the right face that is the lightest) and _a_4 (on the left visible face).

In the second sample Vasya can only see number _a_4.

第一个样例对应的是透视图,如图所示。瓦西娅看到了数字 a2a_2(位于最暗的顶面)、a6a_6(位于最亮的右侧面)以及 a4a_4(位于左侧可见的面)。

在第二个样例中,瓦西娅只能看到数字 a4a_4。

输入解题思路,AI测评打分。不知道怎么写?

首页