fork download
  1. #include <vector>
  2. #include <list>
  3. #include <map>
  4. #include <set>
  5. #include <string>
  6. #include <cstring>
  7. #include <deque>
  8. #include <stack>
  9. #include <bitset>
  10. #include <algorithm>
  11. #include <functional>
  12. #include <numeric>
  13. #include <utility>
  14. #include <sstream>
  15. #include <iostream>
  16. #include <iomanip>
  17. #include <cstdio>
  18. #include <cmath>
  19. #include <cstdlib>
  20. #include <ctime>
  21.  
  22. using namespace std;
  23. long a[111100] = {};
  24. set<long> s;
  25. long n,m,l,x,y;
  26.  
  27. int main () {
  28. cin >> n >> l >> x >> y;
  29. for (int i = 0; i < n; i ++){
  30. cin >> a[i];
  31. s.insert(a[i]);
  32. }
  33. long ans = 0;
  34. for (int i = 0; i < n; i ++){
  35. if (ans % 2 == 0)
  36. if (s.count(a[i]-x) > 0 || s.count(a[i]+x) > 0)
  37. ans = ans | 1;
  38. if ((ans & 2) == 0) { cout << a[i] + y;
  39. if (s.count(a[i]-y) > 0 || s.count(a[i]+y) > 0)
  40. ans = ans | 2;
  41. }
  42. cout << a[i] + y<< " " << ans << endl;
  43. }
  44.  
  45. if (ans == 3) {
  46. cout << 0;
  47. return 0;
  48. }
  49. if (ans == 1) {
  50. printf("%d\n%d",1,y);
  51. return 0;
  52. }
  53. if (ans == 2) {
  54. printf("%d\n%d",1,x);
  55. return 0;
  56. }
  57. for (int i =0; i < n; i ++) {
  58. long t = a[i] - x;
  59. if (t > 0) {
  60. if (s.count(t-y) > 0 || s.count(t+y) > 0) {
  61. printf("%d\n%d",1,t);
  62. return 0;
  63. }
  64. }
  65.  
  66. t = a[i] + x;
  67. if (t <= l) {
  68. if (s.count(t-y) > 0 || s.count(t+y) > 0) {
  69. printf("%d\n%d",1,t);
  70. return 0;
  71. }
  72. }
  73. }
  74. printf("%d\n%d %d",2,x,y);
  75. }
  76.  
Success #stdin #stdout 0s 3912KB
stdin
4 250 185 230
0 20 185 250
stdout
230230 1
250250 3
415 3
480 3
0