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. vs2005中无法修改控件ID

    方法一:撤换到源代码模式下,通过代码更改id 方法二: 1.关闭VS2005: 2.删除目录 C:\Documents and Settings\Administrator\Local Setting ...

  2. 插入排序(Insertion Sort)

    这是排序算法中最常见的排序方法,也是初学者使用最多的.有时候我们在生活中也会不自觉地用到插入排序,例如: 给手里的牌排序 这是最常见的例子之一,我们通常从纸牌的一边开始看,找到一张位置不正确的,把它拿 ...

  3. 链表的基本操作(Basic Operations on a Linked List)

    链表可以进行如下操作: 创建新链表 增加新元素 遍历链表 打印链表 下面定义了对应以上操作的基本函数. 创建新链表 新链表创建之后里面并没有任何元素,我们要为数据在内存中分配节点,再将节点插入链表.由 ...

  4. hdu3870-Catch the Theves(平面图最小割)

    Problem Description A group of thieves is approaching a museum in the country of zjsxzy,now they are ...

  5. PHP计算一个目录文件大小方法

    <?php $dirfile='../hnb'; /** *计算一个目录文件大小方法 *$dirfile:传入文件目录名 **/ function dirSize($dirfile) { $di ...

  6. 对c#剪切板Clipboard占用的问题一点解决方法

    以前在百度写的文档,转移到此处 前几天做一个程序,其中有一个剪切板的操作,具体代码: Clipboard.SetText(“ABC”); 来完成一个复制字符串的操作. 自己调试通过,完全正常,然后就交 ...

  7. 格而知之16:我所理解的Block(3)

    23.在前文中的例子中,Block结构体里的isa指针还没有详细讲解,这个指针都被置向了_NSConcreteStackBlock,它标识了Block的类型. 其实除了_NSConcreteStack ...

  8. poj3358数论(欧拉定理)

    http://poj.org/problem?id=3358 (初始状态为分数形式)小数点进制转换原理:n / m ; n /= gcd( n , m ) ; m/= gcd( n , m ) ; n ...

  9. Firebase远程更新应用

    能打造出色的应用不意味着一定能在商业上取得成功,两者之间还有许多工作要做,绝不能简单发布应用后就宣告“收工”.您需要能迅速根据用户反馈作出调整.测试新功能,以及向用户提供他们最关注的内容. Fireb ...

  10. WeiFenLuo.winFormsUI.Docking.dll的使用(停靠效果)

    1.  重置工具箱: 新建一个WinForm程序,项目名称为TestDockPanelControl.选中Form1窗体后选择工具箱--->>新建个添加选项卡命名为WeiFenLuo--- ...