func_code_string: #include <bits/stdc++.h>   using namespace std;   const double eps = 1e-8;   const double pi = acos(-1.0);   const int INF = 0x3f3f3f3f;   const long long inf = (((long long)1) << 61) + 5;   const int N = 100005;   int f[N];   int g[N];   int a[N];   int bit[N];   int ans[N];   int sum1(int x) {     int ans = 0;     for (int i = x; i > 0; i -= i & -i) ans = max(bit[i], ans);     return ans;   }   void add1(int x, int val) {     for (int i = x; i <= N; i += i & -i) bit[i] = max(bit[i], val);   }   int sum2(int x) {     int ans = 0;     for (int i = x; i <= N; i += i & -i) ans = max(bit[i], ans);     return ans;   }   void add2(int x, int val) {     for (int i = x; i > 0; i -= i & -i) bit[i] = max(bit[i], val);   }   int main() {     int n, res = 0;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       int x = sum1(a[i] - 1);       f[i] = x + 1;       if (f[i] > res) res = f[i];       add1(a[i], f[i]);     }     memset(bit, 0, sizeof bit);     for (int i = n; i >= 1; i--) {       int x = sum2(a[i] + 1);       g[i] = x + 1;       add2(a[i], g[i]);     }     vector<int> q[N];     for (int i = 1; i <= n; i++) {       if (f[i] + g[i] - 1 < res)         ans[i] = 1;       else         q[f[i]].push_back(i);     }     for (int i = 1; i <= res; i++) {       int sz = q[i].size();       for (int j = 0; j < sz; j++) {         int v = q[i][j];         if (sz == 1)           ans[v] = 3;         else           ans[v] = 2;       }     }     for (int i = 1; i <= n; i++) printf( %d , ans[i]);     puts(  );     return 0;   }   