题目描述:
 
 
Long Jumps
 

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 nmarks, 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 a1, a2, ..., an, where ai denotes the distance of the i-th mark from the origin (a1 = 0, an = 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, aj - ai = 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.

Input

The first line contains four positive space-separated integers nlxy (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 a1, a2, ..., an (0 = a1 < a2 < ... < an = l), where ai shows the distance from the i-th mark to the origin.

Output

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 p1, p2, ..., pv (0 ≤ pi ≤ l). Number pi means that the i-th mark should be at the distance of pi centimeters from the origin. Print the marks in any order. If there are multiple solutions, print any of them.

Examples
input
3 250 185 230
0 185 250
output
1
230
input
4 250 185 230
0 20 185 250
output
0
input
2 300 185 230
0 300
output
2
185 230
Note

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.

题目大意:有一把尺子,知道总长度,女生男生跳远的距离x,y(x<y)以及n个已知刻度,问再添加几个刻度才能得到x与y的长度。

解题思路:分类讨论,有三种情况,第一种,不需要添加刻度,第二种,需要添加一个刻度就能间接得到x与y的长度,第三种,不能通过已知刻度以任何方式的加减得到x与y。

因为可能有多钟情况满足要求,所以只需要输出其中一种就行。

AC代码:

# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <iostream>
# include <fstream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <set>
# include <math.h>
# include <algorithm>
using namespace std;
# define pi acos(-1.0)
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define For(i,n,a) for(int i=n; i>=a; --i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define Fo(i,n,a) for(int i=n; i>a ;--i)
typedef long long LL;
typedef unsigned long long ULL; int a[];
map<int,int>M; int main()
{
//freopen("in.txt", "r", stdin);
int q,l,x,y;
cin>>q>>l>>x>>y;
for(int i=;i<=q;i++)
{
cin>>a[i];
M[a[i]]=;
}
int flag1=,flag2=,flag=;
for(int i=;i<=q;i++)
{
if(M[a[i]+x]||M[x])flag1=;
if(M[a[i]+y]||M[y])flag2=;
if(M[a[i]+x+y])flag=a[i]+x;
if(M[a[i]+x-y])
{
if(a[i]+x<=l)flag=a[i]+x;
else if(a[i]-y>=)flag=a[i]-y;
}
}
if(flag1&&flag2)
{
cout<<<<endl;
}
else if(flag1)
{
cout<<<<endl;
cout<<y<<endl;
}
else if(flag2)
{
cout<<<<endl;
cout<<x<<endl;
}
else if(flag)
{
cout<<<<endl;
cout<<flag<<endl;
}
else
{
cout<<<<endl;
cout<<x<<' '<<y<<endl;
}
return ;
}

  

CF 480 B Long Jumps (map标记)的更多相关文章

  1. Northwestern European Regional Contest 2016 NWERC ,F题Free Weights(优先队列+Map标记+模拟)

    传送门: Vjudge:https://vjudge.net/problem/Gym-101170F CF: http://codeforces.com/gym/101170 The city of ...

  2. CF 480 E. Parking Lot

    CF 480 E. Parking Lot http://codeforces.com/contest/480/problem/E 题意: 给一个n*m的01矩阵,每次可以将一个0修改为1,求最大全0 ...

  3. POJ 3320 尺取法,Hash,map标记

    1.POJ 3320 2.链接:http://poj.org/problem?id=3320 3.总结:尺取法,Hash,map标记 看书复习,p页书,一页有一个知识点,连续看求最少多少页看完所有知识 ...

  4. HUD-2112 HDU Today(最短路map标记)

    题目链接:HUD-2112 HDU Today 思路: 1.最短路spfa模板. 2.map标记建图. 3.考虑距离为0或者-1的情况. 总结:下次map记得清空orz. AC代码: #include ...

  5. CF #371 (Div. 2) C、map标记

    1.CF #371 (Div. 2)   C. Sonya and Queries  map应用,也可用trie 2.总结:一开始直接用数组遍历,果断T了一发 题意:t个数,奇变1,偶变0,然后与问的 ...

  6. FZU 2027 单词问题 map标记字符串典型问题

    题目链接:单词问题 找一个字符串里的所有单词,重复的只输出一次.关于map函数key值是字符串的问题一直比较含糊... 挣扎了一番,大概是,map的key值是char型数组的时候,标记的是地址,于是有 ...

  7. codeforces 350 div2 C. Cinema map标记

    C. Cinema time limit per test 2 seconds memory limit per test 256 megabytes input standard input out ...

  8. poj 3320 技巧/尺取法 map标记

    Description Jessica's a very lovely girl wooed by lots of boys. Recently she has a problem. The fina ...

  9. PAT 天梯赛 L1-005. 考试座位号 【MAP标记】

    题目链接 https://www.patest.cn/contests/gplt/L1-005 题意 有一个 考生号,一个试机座位,一个考试座位,给出试机座位,查询 考生号和考试座位 思路 MAP + ...

随机推荐

  1. 【Python】利用豆瓣短评数据生成词云

    在之前的文章中,我们获得了豆瓣爬取的短评内容,汇总到了一个文件中,但是,没有被利用起来的数据是没有意义的. 前文提到,有一篇微信推文的关于词云制作的一个实践记录,准备照此试验一下. 思路分析 读文件 ...

  2. HTML5实现绘制几何图形

    HTML5新增了一个<canvas.../>属性.该元素自身并不绘制图形,只是相当于一张空画布.如果开发者需要向<canvas.../>上绘制图形则必须使用JavaScript ...

  3. 【DSP开发】【Linux开发】基于ARM+DSP进行应用开发

    针对当前应用的复杂性,SOC芯片更好能能满足应用和媒体的需求,集成众多接口,用ARM做为应用处理器进行多样化的应用开发和用户界面和接口,利用DSP进行算法加速,特别是媒体的编解码算法加速,既能够保持算 ...

  4. get与post请求的区别 (面试会问)

    get和post请求是HTTP与服务器交互方式,也就是通常所说的风别对服务器资源的增删改查 1. post是修改数据   get是获得数据 GET在浏览器回退时是无害的,而POST会再次提交请求.(面 ...

  5. Java中HashMap扩容机制思考

    1. HashMap在什么条件下扩容 判断HashMap的数组Size大小如果超过loadFactor*capacity,就要扩容. 相关的类属性: capacity:当前数组容量,始终保持 2^n, ...

  6. php编译完成后,module追加编译进php

    # 如果在编译的时候忘记添加某些模块,可以使用这种办法来重新编译添加! # 首先,进入PHP目录(未编译)的扩展目录 cd /home/soft/php-5.2.14/ext/ftp/ # 调用php ...

  7. HTML DOM中的comfirm()确认对话框

    前言 最近在开发中有一个需求大概就是说:表单点击提交按钮首先弹出确认对话框,然后点击确定请求接口,那么问题来了,我们如何确定点击的是确定还是取消呢? 定义和用法 定义 comfirm()确认对话框,用 ...

  8. linux基本命令之文件浏览(cat,more,less,tail,head),文件操作命令(cp,mv,rm,find)

    linux文件浏览,文件操作命令 文件管理之文件浏览命令 1.cat命令:显示文本文件所有内容 格式:cat 文件名 适用场景:适合只有少量数据的文件,例如只有几行内容的可以使用此命令. 2.more ...

  9. 锋利的jQuery ——jQuery中的事件和动画(四)

    一.jQuery中的事件 1)加载DOM $(document).ready()和window.onload的区别 1>执行时机 $(document).ready(){}  方法内注册的事件, ...

  10. 基于Red5与ffmpeg实现rtmp处理NVR或摄像头的监控视频处理方案

    背景 各大监控视频平台厂商与外对接均是基于IE的OCX插件方式提供实时视频查看.历史视频回放与历史视频下载.在h5已大行其道的当下,基于IE的OCX插件方式已满足不了广大客户的实际需求,因此需要一个兼 ...