func_code_string: #include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   const int MAXN = 1000000;   int n;   char s[MAXN + 1];   int pac[MAXN], npac;   int ast[MAXN], nast;   int prvpac[MAXN], prvast[MAXN];   int mxpos[MAXN];   bool canrgt[MAXN];   int calcmxpos(int i, int t) {     int x = i - t >= 0 ? prvast[i - t] : -1;     if (x == -1) return prvpac[i] == -1 ? i : max(i, prvpac[i] + t);     if (prvpac[i] == -1 || prvpac[i] <= x) return canrgt[x] ? i : -1;     if (prvpac[prvpac[i]] != -1 && prvpac[prvpac[i]] > x)       return mxpos[prvpac[prvpac[i]]] != -1 ? max(i, prvpac[i] + t) : -1;     return canrgt[x] ? max(i, prvpac[i] + t) : mxpos[prvpac[i]] != -1 ? i : -1;   }   bool calccanrgt(int x, int t) {     int i = prvpac[x];     if (i == -1 || x - i > t) return false;     int y = prvast[i];     return mxpos[i] != -1 && mxpos[i] >= x || y == -1 ||            (prvpac[i] != -1 && prvpac[i] > y && mxpos[prvpac[i]] != -1) ||            canrgt[y];   }   bool canall(int t) {     for (int i = (0); i < (n); ++i) {       if (s[i] ==  P ) {         mxpos[i] = calcmxpos(i, t);       }       if (s[i] ==  * ) {         canrgt[i] = calccanrgt(i, t);       }     }     int idx = max(pac[npac - 1], ast[nast - 1]);     if (s[idx] ==  P )       return mxpos[idx] != -1;     else if (s[idx] ==  * )       return canrgt[idx];     else {       assert(false);       return false;     }   }   pair<int, int> solve() {     npac = nast = 0;     for (int i = (0); i < (n); ++i) {       prvast[i] = nast == 0 ? -1 : ast[nast - 1];       prvpac[i] = npac == 0 ? -1 : pac[npac - 1];       if (s[i] ==  P )         pac[npac++] = i;       else if (s[i] ==  * )         ast[nast++] = i;     }     assert(npac > 0 && nast > 0);     if (npac == 1) {       int nleft = 0, tleft = 0, nright = 0, tright = 0;       for (int i = (0); i < (nast); ++i)         if (ast[i] < pac[0]) {           ++nleft;           tleft = max(tleft, pac[0] - ast[i]);         } else {           ++nright;           tright = max(tright, ast[i] - pac[0]);         }       if (nleft > nright || nleft == nright && tleft <= tright)         return make_pair(nleft, tleft);       else         return make_pair(nright, tright);     }     int l = 0, r = n - 1;     while (l + 1 < r) {       int m = l + (r - l) / 2;       if (canall(m))         r = m;       else         l = m;     }     return make_pair(nast, r);   }   void run() {     scanf( %d , &n);     scanf( %s , s);     pair<int, int> ans = solve();     printf( %d %d n , ans.first, ans.second);   }   int main() {     run();     return 0;   }   