func_code_string: #include <bits/stdc++.h>   using namespace std;   int shortestPaths[100][100];   int graph[100][100];   void bfs(int start, int n) {     queue<int> q;     q.push(start);     int visited[n];     for (int i = 0; i < n; i++) {       visited[i] = 0;     }     visited[start] = 1;     int dist = 1;     while (true) {       int sz = q.size();       if (sz == 0) {         break;       }       for (int i = 0; i < sz; i++) {         int cur = q.front();         q.pop();         for (int j = 0; j < 100; j++) {           if (graph[cur][j] == 1 && visited[j] == 0) {             visited[j] = 1;             shortestPaths[start][j] = dist;             q.push(j);           }         }       }       dist++;     }   }   int main() {     ios_base::sync_with_stdio(false);     int n;     cin >> n;     for (int i = 0; i < 100; i++) {       for (int j = 0; j < 100; j++) {         shortestPaths[i][j] = 0;         graph[i][j] = 0;       }     }     for (int i = 0; i < n; i++) {       string s;       cin >> s;       for (int j = 0; j < n; j++) {         graph[i][j] = (int)(s[j] -  0 );       }     }     int m;     cin >> m;     vector<int> vertices;     for (int i = 0; i < m; i++) {       int a;       cin >> a;       a--;       vertices.push_back(a);     }     for (int i = 0; i < n; i++) {       bfs(i, n);     }     vector<int> result;     result.push_back(vertices[0]);     int last = vertices[0];     int ind = 0;     for (int i = 1; i < m; i++) {       if (i != 1) {         if (shortestPaths[last][vertices[i]] < i - ind) {           result.push_back(vertices[i - 1]);           ind = i - 1;           last = vertices[i - 1];         }       }     }     result.push_back(vertices[vertices.size() - 1]);     cout << result.size() << endl;     for (int i = 0; i < result.size(); i++) {       cout << result[i] + 1 <<    ;     }     return 0;   }   