func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 205;   char str[20][N];   int n, m, des;   int dp[20][2];   int call(int flr, int side) {     if (flr == des) {       if (side == 0) {         int p = 0;         for (int i = 1; i <= m; i++)           if (str[flr][i] ==  1 ) p = i;         return p;       } else {         int p = m + 1;         for (int i = m; i >= 1; i--)           if (str[flr][i] ==  1 ) p = i;         return m + 1 - p;       }     }     if (dp[flr][side] != -1) return dp[flr][side];     int ret = 1e9;     if (side == 0) {       ret = min(ret, m + 2 + call(flr - 1, 1));       int p = 0;       for (int i = 1; i <= m; i++)         if (str[flr][i] ==  1 ) p = i;       ret = min(ret, 2 * p + 1 + call(flr - 1, 0));     } else {       ret = min(ret, m + 2 + call(flr - 1, 0));       int p = m + 1;       for (int i = m; i >= 1; i--)         if (str[flr][i] ==  1 ) p = i;       ret = min(ret, (m + 1 - p) * 2 + 1 + call(flr - 1, 1));     }     return dp[flr][side] = ret;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(nullptr);     memset(dp, -1, sizeof(dp));     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> str[i];     des = n - 1;     for (int i = n - 1; i >= 0; i--) {       for (int j = 1; j <= m; j++)         if (str[i][j] ==  1 ) des = i;     }     cout << call(n - 1, 0) <<   n ;   }   