CF479D.Long Jumps

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorite ruler!

However, there is no reason for disappointment, as Valery has found another ruler, its length is l centimeters. The ruler already has n marks, with which he can make measurements. We assume that the marks are numbered from 1 to n in the order they appear from the beginning of the ruler to its end. The first point coincides with the beginning of the ruler and represents the origin. The last mark coincides with the end of the ruler, at distance l from the origin. This ruler can be repesented by an increasing sequence _a_1, _a_2, ..., a__n, where a__i denotes the distance of the i-th mark from the origin (_a_1 = 0, a__n = l).

Valery believes that with a ruler he can measure the distance of d centimeters, if there is a pair of integers i and j (1 ≤ i ≤ j ≤ n), such that the distance between the i-th and the j-th mark is exactly equal to d (in other words, a__j - a__i = d).

Under the rules, the girls should be able to jump at least x centimeters, and the boys should be able to jump at least y (x < y) centimeters. To test the children's abilities, Valery needs a ruler to measure each of the distances x and y.

Your task is to determine what is the minimum number of additional marks you need to add on the ruler so that they can be used to measure the distances x and y. Valery can add the marks at any integer non-negative distance from the origin not exceeding the length of the ruler.

瓦莱里是贝尔兰一所学校的体育老师。很快,学生们将进行立定跳远测试,而瓦莱里却弄丢了他最心爱的直尺!

不过,这并不值得沮丧,因为瓦莱里找到了另一把直尺,其长度为 ll 厘米。这把直尺上已有 nn 个刻度,可用于测量。我们假设这些刻度按从直尺起点到终点的顺序编号为 11 到 nn。第一个刻度与直尺起点重合,即为原点;最后一个刻度与直尺末端重合,距原点距离为 ll。该直尺可用一个严格递增序列 a1, a2, …, ana_1,\,a_2,\,\dots,\,a_n 表示,其中 aia_i 表示第 ii 个刻度距原点的距离(即 a1=0a_1 = 0,an=la_n = l)。

瓦莱里认为:若存在一对整数 ii 和 jj(满足 1≤i≤j≤n1 \le i \le j \le n),使得第 ii 个刻度与第 jj 个刻度之间的距离恰好等于 dd 厘米(即 aj−ai=da_j - a_i = d),则他可用该直尺测量出 dd 厘米的距离。

根据测试规则,女生至少需跳 xx 厘米,男生至少需跳 yy 厘米(其中 x<yx < y)。为了测试学生的跳远能力,瓦莱里需要一把能分别测量出距离 xx 和 yy 的直尺。

你的任务是:确定最少需要在直尺上额外添加多少个刻度,才能使其可以测量出 xx 和 yy 这两个距离。瓦莱里可在距原点任意非负整数距离处(且不超过直尺总长 ll)添加新刻度。

输入格式

The first line contains four positive space-separated integers n, l, x, y (2 ≤ n ≤ 105, 2 ≤ l ≤ 109, 1 ≤ x < y ≤ l) — the number of marks, the length of the ruler and the jump norms for girls and boys, correspondingly.

The second line contains a sequence of n integers _a_1, _a_2, ..., a__n (0 = _a_1 < _a_2 < ... < a__n = l), where a__i shows the distance from the i-th mark to the origin.

第一行包含四个用空格分隔的正整数 nn、ll、xx、yy(满足 2 ≤ n ≤ 1052 \leq n \leq 10^5,2 ≤ l ≤ 1092 \leq l \leq 10^9,1 ≤ x < y ≤ l1 \leq x < y \leq l),分别表示刻度数量、尺子长度,以及女生和男生的跳跃单位长度。

第二行包含一个由 nn 个整数组成的序列 a1, a2, ..., ana_1, a_2, ..., a_n(满足 0 = a1 < a2 < ... < an = l0 = a_1 < a_2 < ... < a_n = l),其中 aia_i 表示第 ii 个刻度到原点的距离。

输出格式

In the first line print a single non-negative integer v — the minimum number of marks that you need to add on the ruler.

In the second line print v space-separated integers _p_1, _p_2, ..., p__v (0 ≤ p__i ≤ l). Number p__i means that the i-th mark should be at the distance of p__i centimeters from the origin. Print the marks in any order. If there are multiple solutions, print any of them.

第一行输出一个非负整数 vv —— 你需要在尺子上添加的最小刻度数量。

第二行输出 vv 个用空格分隔的整数 p1, p2, …, pvp_1,\,p_2,\,\dots,\,p_v(其中 0≤pi≤l0\leq p_i\leq l)。数值 pip_i 表示第 ii 个刻度应位于距原点 pip_i 厘米处。刻度的输出顺序任意。若存在多种解,输出任意一种即可。

输入输出样例

  • 输入#1

    3 250 185 230
    0 185 250

    输出#1

    1
    230
  • 输入#2

    4 250 185 230
    0 20 185 250

    输出#2

    0
  • 输入#3

    2 300 185 230
    0 300

    输出#3

    2
    185 230

说明/提示

In the first sample it is impossible to initially measure the distance of 230 centimeters. For that it is enough to add a 20 centimeter mark or a 230 centimeter mark.

In the second sample you already can use the ruler to measure the distances of 185 and 230 centimeters, so you don't have to add new marks.

In the third sample the ruler only contains the initial and the final marks. We will need to add two marks to be able to test the children's skills.

在第一个样例中,最初无法测量 230 厘米的距离。为此,只需添加一个 20 厘米的刻度或一个 230 厘米的刻度即可。

在第二个样例中,你已可使用该直尺测量 185 厘米和 230 厘米的距离,因此无需添加新的刻度。

在第三个样例中,直尺仅包含初始刻度和最终刻度。我们需要添加两个刻度,才能测试孩子们的技能。

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

首页