CF1020A.New Building for SIS
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are looking at the floor plan of the Summer Informatics School's new building. You were tasked with SIS logistics, so you really care about travel time between different locations: it is important to know how long it would take to get from the lecture room to the canteen, or from the gym to the server room.
The building consists of n towers, h floors each, where the towers are labeled from 1 to n, the floors are labeled from 1 to h. There is a passage between any two adjacent towers (two towers i and i + 1 for all i: 1 ≤ i ≤ n - 1) on every floor x, where a ≤ x ≤ b. It takes exactly one minute to walk between any two adjacent floors of a tower, as well as between any two adjacent towers, provided that there is a passage on that floor. It is not permitted to leave the building.

The picture illustrates the first example.
You have given k pairs of locations (t__a, f__a), (t__b, f__b): floor f__a of tower t__a and floor f__b of tower t__b. For each pair you need to determine the minimum walking time between these locations.
你正在查看暑期信息学学校新大楼的平面图。你负责SIS的后勤工作,因此特别关注不同地点之间的通行时间:了解从报告厅到食堂、或从健身房到服务器机房所需的时间非常重要。
该建筑由 n 座塔楼组成,每座塔楼有 h 层;塔楼编号为 1 至 n,楼层编号为 1 至 h。对于任意两个相邻塔楼(即塔楼 i 与 i+1,其中所有满足 1≤i≤n−1 的 i),在每一层 x(其中 a≤x≤b)均设有连廊。在塔楼内上下相邻楼层之间步行,或在相邻塔楼间(当该楼层存在连廊时)步行,均恰好耗时一分钟。不允许离开建筑物。

该图展示了第一个样例。
你收到了 k 对位置 $ (t_a,,f_a),\ (t_b,,f_b) $:即塔楼 ta 的第 fa 层与塔楼 tb 的第 fb 层。对每一对位置,你需要计算这两点之间的最短步行时间。
输入格式
The first line of the input contains following integers:
- n: the number of towers in the building (1 ≤ n ≤ 108),
- h: the number of floors in each tower (1 ≤ h ≤ 108),
- a and b: the lowest and highest floor where it's possible to move between adjacent towers (1 ≤ a ≤ b ≤ h),
- k: total number of queries (1 ≤ k ≤ 104).
Next k lines contain description of the queries. Each description consists of four integers t__a, f__a, t__b, f__b (1 ≤ t__a, t__b ≤ n, 1 ≤ f__a, f__b ≤ h). This corresponds to a query to find the minimum travel time between f__a-th floor of the t__a-th tower and f__b-th floor of the t__b-th tower.
输入的第一行包含以下整数:
- n:建筑中塔的数量(1 ≤ n ≤ 108),
- h:每座塔的楼层数(1 ≤ h ≤ 108),
- a 和 b:可在相邻塔之间通行的最低与最高楼层(1 ≤ a ≤ b ≤ h),
- k:查询总数(1 ≤ k ≤ 104)。
接下来的 k 行描述各次查询。每次查询由四个整数 ta、fa、tb、fb 组成(1 ≤ ta,tb ≤ n,1 ≤ fa,fb ≤ h)。这表示一次查询,要求计算从第 ta 座塔的第 fa 层到第 tb 座塔的第 fb 层的最短通行时间。
输出格式
For each query print a single integer: the minimum walking time between the locations in minutes.
对于每个查询,输出一个整数:两地之间最短步行时间(单位:分钟)。
输入输出样例
输入#1
3 6 2 3 3 1 2 1 3 1 4 3 4 1 2 2 3
输出#1
1 4 2
输入解题思路,AI测评打分。不知道怎么写?