CF15B.Laser

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:64MB

AC君温馨提醒

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

题目描述

Petya is the most responsible worker in the Research Institute. So he was asked to make a very important experiment: to melt the chocolate bar with a new laser device. The device consists of a rectangular field of n × m cells and a robotic arm. Each cell of the field is a 1 × 1 square. The robotic arm has two lasers pointed at the field perpendicularly to its surface. At any one time lasers are pointed at the centres of some two cells. Since the lasers are on the robotic hand, their movements are synchronized — if you move one of the lasers by a vector, another one moves by the same vector.

The following facts about the experiment are known:

  • initially the whole field is covered with a chocolate bar of the size n × m, both lasers are located above the field and are active;
  • the chocolate melts within one cell of the field at which the laser is pointed;
  • all moves of the robotic arm should be parallel to the sides of the field, after each move the lasers should be pointed at the centres of some two cells;
  • at any one time both lasers should be pointed at the field. Petya doesn't want to become a second Gordon Freeman.

You are given n, m and the cells (_x_1, _y_1) and (_x_2, _y_2), where the lasers are initially pointed at (x__i is a column number, y__i is a row number). Rows are numbered from 1 to m from top to bottom and columns are numbered from 1 to n from left to right. You are to find the amount of cells of the field on which the chocolate can't be melted in the given conditions.

佩佳是研究所里最负责任的员工。因此,他被要求进行一项非常重要的实验:使用一种新型激光设备熔化一块巧克力。该设备由一个 n×mn \times m 的矩形网格区域和一条机械臂组成。网格中的每个单元格都是一个 1×11 \times 1 的正方形。机械臂上装有两束激光,均垂直照射于网格表面。在任意时刻,这两束激光分别对准某两个单元格的中心。由于两束激光安装在同一机械臂上,它们的运动是同步的——若将其中一束激光沿某一向量移动,则另一束激光也沿完全相同的向量移动。

关于该实验,已知以下事实:

  • 初始时,整个 n×mn \times m 网格区域被一块完整的巧克力覆盖;两束激光均位于网格上方且处于开启状态;
  • 激光所对准的单元格内的巧克力将会被熔化;
  • 机械臂的所有移动必须与网格的边平行;每次移动后,两束激光仍需分别对准某两个单元格的中心;
  • 在任意时刻,两束激光都必须对准网格区域内部(即不能指向网格外)。佩佳可不想成为第二个戈登·弗里曼(Gordon Freeman)。

给定 nn、mm 以及初始时两束激光所对准的单元格坐标 (x1,y1)(x_1, y_1) 和 (x2,y2)(x_2, y_2)(其中 xix_i 表示列号,yiy_i 表示行号)。行号从上到下编号为 11 至 mm,列号从左到右编号为 11 至 nn。你需要求出:在给定条件下,无法被熔化的单元格数量。

输入格式

The first line contains one integer number t (1 ≤ t ≤ 10000) — the number of test sets. Each of the following t lines describes one test set. Each line contains integer numbers n, m, _x_1, _y_1, _x_2, _y_2, separated by a space (2 ≤ n, m ≤ 109, 1 ≤ _x_1, _x_2 ≤ n, 1 ≤ _y_1, _y_2 ≤ m). Cells (_x_1, _y_1) and (_x_2, _y_2) are distinct.

第一行包含一个整数 $ t (( 1 \leq t \leq 10000 $)——测试用例的数量。接下来的 $ t $ 行,每行描述一个测试用例。每行包含由空格分隔的整数 $ n 、、 m 、、 x_1 、、 y_1 、、 x_2 、、 y_2 $(其中 $ 2 \leq n, m \leq 10^9 ,, 1 \leq x_1, x_2 \leq n ,, 1 \leq y_1, y_2 \leq m $)。格子 $ (x_1, y_1) $ 与 $ (x_2, y_2) $ 是不同的。

输出格式

Each of the t lines of the output should contain the answer to the corresponding input test set.

输出的每行(共 tt 行)应包含对应输入测试用例的答案。

输入输出样例

  • 输入#1

    2
    4 4 1 1 3 3
    4 3 1 1 2 2

    输出#1

    8
    2

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

首页