func_code_string: #include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const int maxn = 2e6 + 7;   char str[maxn];   int ans[10][10], used[10];   int mp[10][10][10][10];   struct NODE {     int num, step;   };   int bfs(int numa, int numb, int a, int b) {     queue<NODE> que;     memset(used, 0, sizeof(used));     que.push((NODE){numa, 0});     while (!que.empty()) {       NODE now = que.front();       que.pop();       int x = (now.num + a) % 10;       int y = (now.num + b) % 10;       if (x == numb || y == numb) return now.step;       if (!used[x]) {         used[x] = 1;         que.push((NODE){x, now.step + 1});       }       if (!used[y]) {         used[y] = 1;         que.push((NODE){y, now.step + 1});       }     }     return -1;   }   int main() {     for (auto i = 0; i < 10; i++) {       for (auto j = i; j < 10; j++) {         for (auto numa = 0; numa < 10; numa++) {           for (auto numb = 0; numb < 10; numb++) {             int Insert = bfs(numa, numb, i, j);             if (Insert == -1) {               mp[i][j][numa][numb] = mp[j][i][numa][numb] = -1;               continue;             } else               mp[i][j][numa][numb] = mp[j][i][numa][numb] = Insert;           }         }       }     }     scanf( %s , str);     int len = strlen(str);     for (auto i = 0; i < 10; i++) {       for (auto j = i; j < 10; j++) {         for (auto p = 1; p < len; p++) {           int numa = str[p - 1] -  0 ;           int numb = str[p] -  0 ;           int Insert = mp[i][j][numa][numb];           if (Insert == -1) {             ans[i][j] = ans[j][i] = -1;             break;           } else {             ans[i][j] += Insert;             if (i != j) ans[j][i] += Insert;           }         }       }     }     for (auto i = 0; i < 10; i++) {       for (auto j = 0; j < 10; j++) {         printf( %d  , ans[i][j]);       }       puts(  );     }     return 0;   }   