func_code_string: #include <bits/stdc++.h>   using namespace std;   inline void pisz(int n) { printf( %d n , n); }   const int fx[4][2] = {{0, 1}, {-1, 0}, {0, -1}, {1, 0}};   const int fxx[9][2] = {{0, 0}, {0, 1},  {0, -1}, {1, 0},  {-1, 0},                          {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};   const int N = 500;   const long long mod = 1000000007;   struct FenwickTreeMax {     vector<int> bit;     int n;     FenwickTreeMax(int n) {       this->n = n;       bit.assign(n, 0);     }     FenwickTreeMax(vector<int> a) : FenwickTreeMax(a.size()) {       for (size_t i = 0; i < a.size(); i++) update(i, a[i]);     }     int getmax(int r) {       int ret = 0;       for (; r >= 0; r = (r & (r + 1)) - 1) ret = (ret < bit[r] ? bit[r] : ret);       return ret;     }     int pos_val(int r) { return bit[r]; }     void update(int idx, int val) {       for (; idx < n; idx = idx | (idx + 1))         bit[idx] = (bit[idx] < val ? val : bit[idx]);     }   };   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n;     cin >> n;     string s;     cin >> s;     vector<long long> pos[26];     for (long long i = 0; i < n; i++) {       pos[s[i] -  a ].push_back(i);     }     FenwickTreeMax ft(n);     vector<long long> output(n, -1);     long long maxi = 0;     for (long long i = 25; i >= 0; i--) {       if (pos[i].size() == 0) continue;       vector<long long> col;       for (auto x : pos[i]) {         output[x] = ft.getmax(x) + 1;         maxi = (output[x] < maxi ? maxi : output[x]);       }       for (auto x : pos[i]) {         ft.update(x, output[x]);       }     }     cout << maxi <<   n ;     for (long long i = 0; i < n; i++) {       cout << output[i] <<    ;     }   }   