func_code_string: #include <bits/stdc++.h>   using namespace std;   void desperate_optimization(int precision) {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cout.setf(ios::fixed);     cout.setf(ios::showpoint);     cout.precision(precision);   }   const int N = 2e5;   int arr[N + 5];   int pre[N + 5];   int mark[N + 5];   vector<int> lis;   void hora(int tc) {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> arr[i];       mark[i] = 1;       if (lis.size() == 0 || arr[lis.back()] < arr[i]) {         pre[i] = -1;         if (lis.size() != 0) pre[i] = lis.back();         lis.push_back(i);       } else {         int lo = 0;         int hi = lis.size() - 1;         int res = -1;         while (lo <= hi) {           int mid = (lo + hi) / 2;           if (arr[lis[mid]] >= arr[i]) {             res = mid;             hi = mid - 1;           } else             lo = mid + 1;         }         lis[res] = i;         pre[i] = -1;         if (res != 0) pre[i] = lis[res - 1];       }     }     int tmp = lis.back();     for (int i = 0; i < n; i++) {       if (pre[tmp] == pre[i] && arr[tmp] < arr[i]) tmp = i;     }     while (tmp != -1) {       mark[tmp] = 0;       tmp = pre[tmp];     }     int hi = 1e9;     int lo = -1;     bool ada = true;     for (int i = 0; i < n; i++) {       if (mark[i] == 0) {         if (lo >= arr[i]) ada = false;         lo = arr[i];       } else {         if (hi <= arr[i]) ada = false;         hi = arr[i];       }     }     if (ada == false) {       lis.clear();       for (int i = 0; i < n; i++) {         mark[i] = 0;         if (lis.size() == 0 || arr[lis.back()] > arr[i]) {           pre[i] = -1;           if (lis.size() != 0) pre[i] = lis.back();           lis.push_back(i);         } else {           int lo = 0;           int hi = lis.size() - 1;           int res = -1;           while (lo <= hi) {             int mid = (lo + hi) / 2;             if (arr[lis[mid]] <= arr[i]) {               res = mid;               hi = mid - 1;             } else               lo = mid + 1;           }           lis[res] = i;           pre[i] = -1;           if (res != 0) pre[i] = lis[res - 1];         }       }       int tmp = lis.back();       for (int i = 0; i < n; i++) {         if (pre[tmp] == pre[i] && arr[tmp] > arr[i]) tmp = i;       }       while (tmp != -1) {         mark[tmp] = 1;         tmp = pre[tmp];       }       int hi = 1e9;       int lo = -1;       bool ada = true;       for (int i = 0; i < n; i++) {         if (mark[i] == 0) {           if (lo >= arr[i]) ada = false;           lo = arr[i];         } else {           if (hi <= arr[i]) ada = false;           hi = arr[i];         }       }       if (ada == false)         cout <<  NO  <<   n ;       else {         cout <<  YES  <<   n ;         for (int i = 0; i < n; i++) cout << mark[i] <<    ;         cout <<   n ;       }     } else {       cout <<  YES  <<   n ;       for (int i = 0; i < n; i++) cout << mark[i] <<    ;       cout <<   n ;     }   }   int main() {     desperate_optimization(10);     int ntc = 1;     for (int tc = 1; tc <= ntc; tc++) hora(tc);     return 0;   }   