Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.27 KB | None | 0 0
  1. #include <vector>
  2. #include <string>
  3. #include <iostream>
  4. #include <cstdio>
  5. #include <algorithm>
  6. #include <stack>
  7. #include <queue>
  8. #include <deque>
  9. #include <set>
  10. #include <map>
  11. #include <cmath>
  12. #include <unordered_map>
  13. #include <unordered_set>
  14. #include <numeric>
  15. #include <fstream>
  16. #include <functional>
  17. #include <iomanip>
  18. #include <cctype>
  19. #include <iterator>
  20. #include <utility>
  21. #include <bitset>
  22. #include <tuple>
  23.  
  24. #define frt(s, n, t) for(int i = s; (i > n && t < 0) || (i < n && t > 0); i += t)
  25. #define fr(s, n) for (int i = s; i < n; i++)
  26. #define frj(s, n) for (int j = 0; j < n; j++)
  27. #define eol "\n"
  28. #define pb push_back
  29. #define ft first
  30. #define sd second
  31.  
  32. using namespace std;
  33.  
  34. typedef long long unsigned ull;
  35. typedef long long ll;
  36.  
  37. typedef unordered_map<int, int> umii;
  38. typedef unordered_set<int> usi;
  39. typedef unordered_set<ll> usll;
  40. typedef unordered_set<ull> usull;
  41. typedef vector<int> vint;
  42. typedef pair<int, int> pairI;
  43. typedef pair<string, int> psi;
  44. typedef vector<pair<int, int>> vpi;
  45.  
  46. int main() {
  47.     //ifstream in("input.txt");
  48.     //ofstream out("output.txt");
  49.     ios::sync_with_stdio(0);
  50.     cin.tie(NULL);
  51.     int INF = 1e9;
  52.     int a, b, c, d;
  53.     cin >> a >> b >> c >> d;
  54.     deque<int> start, middle, end;
  55.     int c1 = min(a, b), c2 = min(c, d);
  56.     fr(0, c1) {
  57.         start.push_back(0);
  58.         start.push_back(1);
  59.         b--;
  60.         a--;
  61.     }
  62.     fr(0, c2) {
  63.         end.push_back(2);
  64.         end.push_back(3);
  65.         c--;
  66.         d--;
  67.     }
  68.     if (a == 1) {
  69.         start.push_back(0);
  70.         a--;
  71.     }
  72.     if (d == 1) {
  73.         end.push_front(3);
  74.         d--;
  75.     }
  76.     if (a > 0 || d > 0 || abs(c - b) > 1) {
  77.         cout << "NO";
  78.         exit(0);
  79.     }
  80.     else {
  81.         if (c > b) {
  82.             end.push_back(2);
  83.             c--;
  84.         }
  85.         else if (b > c) {
  86.             start.push_front(1);
  87.             b--;
  88.         }
  89.         fr(0, b) {
  90.             middle.push_back(2);
  91.             middle.push_back(1);
  92.         }
  93.         if ((middle.empty() + start.empty() + end.empty() == 2) || (middle.empty() && abs(start.back()-end.front()) == 1) || (middle.size() && (start.empty() || abs(middle.front() - start.back()) == 1) && (end.empty() || abs(middle.back() - end.front()) == 1))) {
  94.             cout << "YES" << eol;
  95.             for (int x : start) {
  96.                 cout << x << " ";
  97.             }
  98.             for (int x : middle) {
  99.                 cout << x << " ";
  100.             }
  101.             for (int x : end) {
  102.                 cout << x << " ";
  103.             }
  104.         }
  105.         else {
  106.             cout << "NO";
  107.         }
  108.     }
  109.     return 0;
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement