D. Long Jumps
time limit per test 1 second
memory limit per test 256 megabytes
input standard input
output standard output

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 aidenotes 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.

Sample test(s)
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.

求最少要加几个数使得存在a[i]-a[j]=x,a[k]-a[l]=y

毕竟我逗比了……wa了6次之后又被x了

各种无脑二分就过了

 #include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<ctime>
#define LL long long
#define inf 0x7ffffff
#define pa pair<int,int>
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
LL n,L,x,y;
LL a[];
bool xx,yy,xy,yx;
LL xxyy,yyxx;
inline LL read()
{
LL x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
inline bool bsearch(LL x)
{
int l=,r=n;
while (l<=r)
{
int mid=(l+r)>>;
if (a[mid]==x)return ;
if (a[mid]<x)l=mid+;
if (a[mid]>x)r=mid-;
}
return ;
}
int main()
{
n=read();L=read();x=read();y=read();
for (int i=;i<=n;i++)a[i]=read();
sort(a+,a+n+);
for(int i=;i<=n;i++)
{
if (bsearch(a[i]+x))xx=,printf("xx %d\n",i);
if (bsearch(a[i]+y))yy=,printf("yy %d\n",i);
if (bsearch(a[i]+x+y))xy=,xxyy=a[i]+x;
if (bsearch(a[i]+y-x))
{
if(a[i]+y<=L) {yyxx=a[i]+y;yx=;}
if(a[i]-x>=) {yyxx=a[i]-x;yx=;}
}
}
if (xx&&yy)
{
printf("0\n");
}else
if (xx&&!yy)
{
printf("1\n%lld\n",y);
}else
if (yy&&!xx)
{
printf("1\n%lld\n",x);
}else
if (!xx&&!yy&&xy)
{
printf("1\n%lld\n",xxyy);
}else
if (!xx&!yy&&yx)
{
printf("1\n%lld\n",yyxx);
}else
{
printf("2\n%lld %lld\n",x,y);
}
}

cf479D

cf479D Long Jumps的更多相关文章

  1. codeforces 480B B. Long Jumps(贪心)

    题目链接: B. Long Jumps time limit per test 1 second memory limit per test 256 megabytes input standard ...

  2. Codeforces Round #274 (Div. 1) B. Long Jumps 数学

    B. Long Jumps Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/480/problem/ ...

  3. Codeforces 479D - Long Jumps

    479D - Long Jumps, 480B - Long Jumps It , or . If we can already measure both x and y, output . Then ...

  4. the quick brown fox jumps over the lazy dog

    THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG

  5. [CF791D]Bear and Tree Jumps

    题目描述 A tree is an undirected connected graph without cycles. The distance between two vertices is th ...

  6. vim使用跳转列表 jumps 来跟踪 (历史位置的)导航

    参考: Vim使用跳转列表来跟踪你的导航,你可以通过这个列表来向前或者向后导航. 跳转列表保留所有地方的轨迹,它可以跟踪文件名.行号和列号. 查看调整列表::jumps 导航键 描述 CTRL-o 跳 ...

  7. python json (loads(),load(),jump(),jumps())

    # loads() str to json data# jumps() json to str# jump() json to filedef ladstest(): data = '{"n ...

  8. zabbix监控cpu jumps

    cpu监控图形分为三种 cpu jumps cpu突发 包含 context switches per second 进程线程切换 interrupts per second 每秒的中断次数 cpu ...

  9. Long Jumps(二分查找lower_bound()函数的运用)

    Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long ju ...

随机推荐

  1. C# -- 扩展方法的应用(Extension Methods)

    当你有下面这样一个需求的时候,扩展方法就会起到作用:在项目中,类A需要添加功能,我们想到的就是在类A中添加公共方法,这个显而易见肯定可以,但是由于某种原因,你不能修改类A本身的代码,但是确实又需要增加 ...

  2. vi常用命令集锦

    转载,原文地址:http://blog.csdn.net/hackbuteer1/article/details/6575232 vi编辑器有3种模式:命令模式.输入模式.末行模式.掌握这三种模式十分 ...

  3. 整个Html内容以邮件的方式发送出去(取出标签包含的用户输入信息)

    需求是一个html的调查问卷,在调查问卷完成后,将问卷页面(包括用户填写的答案)完整的发送给领导. 问题出现了 填写的时候用的是jquery赋值的方法 ,比如text文本.textrear用的是val ...

  4. 虚拟机IOS开发环境搭建教程

    来源:http://www.cnblogs.com/xiaoyaoju/archive/2013/05/21/3091171.html 安装条件: 硬件:一台拥有支持虚拟技术的64位双核处理器和2GB ...

  5. [Cycle.js] Hyperscript as our alternative to template languages

    Usually we use template languages like Handlebars, JSX, and Jade to create. One simple way we can cr ...

  6. Qt Assistant 的配置文件qhp--->qch 和qhcp--->qhc详解与生成

      Qt Assistant 这个exe文件可以被我们利用到我们自己的程序为我们添加help,是一个文档浏览器,它的搜索功能,还有最主要的就是他可以让客户自己定义自己索要显示的文档,也就是qch文档. ...

  7. magic Ajax使用以及注意事项

    以下是引用片段:一.概述    现在Ajax技术正如火如荼的在Internet上发展着.而面对我们之前开发的ASP.NET1.1的Web项目,类似于下拉框等联动也需要啪啪啪的不断刷新,的确影响到了用户 ...

  8. asp.net同时调用JS和后台的无效的解决

    如果js是个定时器,那么就不走后台 <asp:Button runat="server" type="button" Text="重新发送邮件& ...

  9. Linux 与 unix shell编程指南——学习笔记

    第一章    文件安全与权限 文件访问方式:读,写,执行.     针对用户:文件属主,同组用户,其它用户.     文件权限位最前面的字符代表文件类型,常用的如         d 目录:l 符号链 ...

  10. vs2012 boost配置

    1.去www.boost.org下载最新的boost,我下载了boost_1_60_02.(我放在D:/cpp目录下)解压到当前文件夹3.打开VS2012->VS TOOLS->VS命令提 ...