CF424D.Biathlon Track

提高+/省选-

通过率:0%

时间限制:4.50s

内存限制:256MB

AC君温馨提醒

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

题目描述

Recently an official statement of the world Olympic Committee said that the Olympic Winter Games 2030 will be held in Tomsk. The city officials decided to prepare for the Olympics thoroughly and to build all the necessary Olympic facilities as early as possible. First, a biathlon track will be built.

To construct a biathlon track a plot of land was allocated, which is a rectangle divided into n × m identical squares. Each of the squares has two coordinates: the number of the row (from 1 to n), where it is located, the number of the column (from 1 to m), where it is located. Also each of the squares is characterized by its height. During the sports the biathletes will have to move from one square to another. If a biathlete moves from a higher square to a lower one, he makes a descent. If a biathlete moves from a lower square to a higher one, he makes an ascent. If a biathlete moves between two squares with the same height, then he moves on flat ground.

The biathlon track should be a border of some rectangular area of the allocated land on which biathletes will move in the clockwise direction. It is known that on one move on flat ground an average biathlete spends t__p seconds, an ascent takes t__u seconds, a descent takes t__d seconds. The Tomsk Administration wants to choose the route so that the average biathlete passes it in as close to t seconds as possible. In other words, the difference between time t__s of passing the selected track and t should be minimum.

For a better understanding you can look at the first sample of the input data. In this sample n = 6, m = 7, and the administration wants the track covering time to be as close to t = 48 seconds as possible, also, t__p = 3, t__u = 6 and t__d = 2. If we consider the rectangle shown on the image by arrows, the average biathlete can move along the boundary in a clockwise direction in exactly 48 seconds. The upper left corner of this track is located in the square with the row number 4, column number 3 and the lower right corner is at square with row number 6, column number 7.

Among other things the administration wants all sides of the rectangle which boundaries will be the biathlon track to consist of no less than three squares and to be completely contained within the selected land.

You are given the description of the given plot of land and all necessary time values. You are to write the program to find the most suitable rectangle for a biathlon track. If there are several such rectangles, you are allowed to print any of them.

近日,国际奥委会发布官方声明,宣布2030年冬奥会将在托木斯克举行。该市官员决定全面开展奥运筹备工作,并尽早建设所有必要的奥运设施。首先将修建一个冬季两项赛道。

为修建冬季两项赛道,已划拨一块矩形土地,该土地被划分为 n×mn \times m 个完全相同的正方形小格。每个小格具有两个坐标:所在行号(从 11 到 nn)和所在列号(从 11 到 mm)。此外,每个小格还具有一个高度值。在比赛中,冬季两项运动员需在小格之间移动:若从较高小格移向较低小格,则为下坡;若从较低小格移向较高小格,则为上坡;若在两个高度相同的小格间移动,则为平地。

冬季两项赛道应为所划拨土地中某个矩形区域的边界,运动员须沿该边界按顺时针方向行进。已知:平均运动员在平地上每步耗时 tpt_p 秒,上坡每步耗时 tut_u 秒,下坡每步耗时 tdt_d 秒。托木斯克市政府希望选择一条路线,使得平均运动员通过该赛道所用时间尽可能接近 tt 秒,即:使所选赛道的实际通行时间 tst_s 与目标时间 tt 的差值 ∣ts−t∣|t_s - t| 最小。

为便于理解,可参考输入样例一。该样例中 n=6n = 6,m=7m = 7,市政府希望赛道通行时间尽可能接近 t=48t = 48 秒,且 tp=3t_p = 3,tu=6t_u = 6,td=2t_d = 2。若考虑图中箭头所示的矩形区域,则平均运动员恰好可在 48 秒内沿其边界顺时针行进一圈。该赛道的左上角位于第 44 行、第 33 列的小格,右下角位于第 66 行、第 77 列的小格。

此外,市政府还要求:作为冬季两项赛道边界的矩形,其四条边每条均至少包含三个小格,且整个矩形必须完全落在所划拨的土地范围内。

现给出该地块的高度数据及所有必要的时间参数,请编写程序找出最合适的冬季两项赛道矩形。若存在多个满足条件的矩形,输出任意一个即可。

输入格式

The first line of the input contains three integers n, m and t (3 ≤ n, m ≤ 300, 1 ≤ t ≤ 109) — the sizes of the land plot and the desired distance covering time.

The second line also contains three integers t__p, t__u and t__d (1 ≤ t__p, t__u, t__d ≤ 100) — the time the average biathlete needs to cover a flat piece of the track, an ascent and a descent respectively.

Then n lines follow, each line contains m integers that set the heights of each square of the given plot of land. Each of the height values is a positive integer, not exceeding 106.

输入的第一行包含三个整数 nn、mm 和 tt(3 ≤ n, m ≤ 3003 \leq n, m \leq 300,1 ≤ t ≤ 1091 \leq t \leq 10^9)——分别表示地块的尺寸以及期望的总用时。

第二行也包含三个整数 tpt_p、tut_u 和 tdt_d(1 ≤ tp, tu, td ≤ 1001 \leq t_p, t_u, t_d \leq 100)——分别表示一名普通冬季两项运动员通过平地、上坡和下坡路段各需的时间。

随后是 nn 行,每行包含 mm 个整数,表示该地块每个方格的高度。每个高度值均为不超过 10610^6 的正整数。

输出格式

In a single line of the output print four positive integers — the number of the row and the number of the column of the upper left corner and the number of the row and the number of the column of the lower right corner of the rectangle that is chosen for the track.

在输出的一行中,打印四个正整数——所选赛道矩形的左上角所在行号与列号,以及右下角所在行号与列号。

输入输出样例

  • 输入#1

    6 7 48
    3 6 2
    5 4 8 3 3 7 9
    4 1 6 8 7 1 1
    1 6 4 6 4 8 6
    7 2 6 1 6 9 4
    1 9 8 6 3 9 2
    4 5 6 8 4 3 7

    输出#1

    4 3 6 7

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

首页