func_code_string: #include <bits/stdc++.h>   #pragma GCC optimize(2)   using namespace std;   const int maxn = 2e5;   const int INF = 0x7fffffff;   const int mod = 1e9 + 7;   const double eps = 1e-7;   const double Pi = acos(-1.0);   inline int read_int() {     char c;     int ret = 0, sgn = 1;     do {       c = getchar();     } while ((c <  0  || c >  9 ) && c !=  - );     if (c ==  - )       sgn = -1;     else       ret = c -  0 ;     while ((c = getchar()) >=  0  && c <=  9 ) ret = ret * 10 + (c -  0 );     return sgn * ret;   }   inline long long read_ll() {     char c;     long long ret = 0, sgn = 1;     do {       c = getchar();     } while ((c <  0  || c >  9 ) && c !=  - );     if (c ==  - )       sgn = -1;     else       ret = c -  0 ;     while ((c = getchar()) >=  0  && c <=  9 ) ret = ret * 10 + (c -  0 );     return sgn * ret;   }   int n, arr[maxn + 5], res[maxn + 5];   vector<int> dc, ic;   int main() {     n = read_int();     for (int i = 1; i <= n; ++i) arr[i] = read_int();     for (int i = 1; i <= n; ++i) {       if (dc.empty() && ic.empty()) {         if (i < n && arr[i] <= arr[i + 1])           ic.push_back(i);         else           dc.push_back(i);       } else if (dc.empty()) {         int id = ic.back();         if (arr[i] <= arr[id])           dc.push_back(i);         else {           if (i + 1 <= n && arr[i] <= arr[i + 1])             ic.push_back(i);           else             dc.push_back(i);         }       } else if (ic.empty()) {         int id = dc.back();         if (arr[i] >= arr[id])           ic.push_back(i);         else {           if (i + 1 <= n && arr[i] <= arr[i + 1])             ic.push_back(i);           else             dc.push_back(i);         }       } else {         int id1 = ic.back(), id2 = dc.back();         if (arr[i] <= arr[id1] && arr[i] >= arr[id2]) {           cout <<  NO  << endl;           return 0;         } else if (arr[i] > arr[id1] && arr[i] < arr[id2]) {           if (i + 1 <= n && arr[i] <= arr[i + 1])             ic.push_back(i);           else             dc.push_back(i);         } else if (arr[i] > arr[id1])           ic.push_back(i);         else           dc.push_back(i);       }     }     for (int i = 0; i < dc.size(); ++i) res[dc[i]] = 1;     cout <<  YES  << endl;     for (int i = 1; i <= n; ++i) printf( %d%c , res[i],    n [i == n]);     return 0;   }   