func_code_string: #include <bits/stdc++.h>   using namespace std;   struct SCC {     int N;     vector<bool> used;     vector<int> vs;     vector<int> cmp;     void dfs(int v, const vector<int> G[]) {       used[v] = true;       for (auto u : G[v]) {         if (!used[u]) dfs(u, G);       }       vs.push_back(v);     }     void rdfs(int v, int k, const vector<int> rG[]) {       used[v] = true;       cmp[v] = k;       for (auto u : rG[v]) {         if (!used[u]) rdfs(u, k, rG);       }     }     void calculate(int Nin, const vector<int> G[], const vector<int> rG[]) {       N = Nin;       used.resize(N);       fill(used.begin(), used.end(), false);       for (int v = 0; v < N; v++) {         if (!used[v]) dfs(v, G);       }       fill(used.begin(), used.end(), false);       cmp.resize(N);       int k = 0;       for (int i = vs.size() - 1; i >= 0; i--) {         if (!used[vs[i]]) rdfs(vs[i], k++, rG);       }     }     int dump_graph(const vector<int> G[], vector<int> edges2[]) {       for (int i = 0; i < N; i++) {         for (auto j : G[i]) {           if (cmp[i] != cmp[j]) {             edges2[cmp[i]].push_back(cmp[j]);           }         }       }       return *max_element(cmp.begin(), cmp.end()) + 1;     }   };   vector<int> edges[5000000], edges2[5000000];   int main() {     int N, M, D;     cin >> N >> M >> D;     for (int i = 0; i < M; i++) {       int a, b;       scanf( %d %d , &a, &b);       a--;       b--;       for (int d = 0; d < D; d++) {         int s = a * D + d, t = b * D + (d + 1) % D;         edges[s].push_back(t);         edges2[t].push_back(s);       }     }     SCC scc;     scc.calculate(D * N, edges, edges2);     for (int i = 0; i < N * D; i++) edges2[i].clear();     int N2 = scc.dump_graph(edges, edges2);     vector<int> num(N * D);     char s[50];     for (int i = 0; i < N; i++) {       scanf( %s , s);       set<int> st;       for (int d = 0; d < D; d++) {         if (s[d] ==  0 ) continue;         int c = scc.cmp[i * D + d];         if (!st.count(c)) {           num[c]++;           st.insert(c);         }       }     }     vector<int> indeg(N2);     for (int i = 0; i < N2; i++)       for (int j : edges2[i]) indeg[j]++;     vector<int> dp(N2);     queue<int> que;     for (int i = 0; i < N2; i++) {       dp[i] = -1e9;       if (indeg[i] == 0) que.push(i);     }     int st = scc.cmp[0];     dp[st] = num[st];     while (que.size()) {       int i = que.front();       que.pop();       for (int j : edges2[i]) {         dp[j] = max(dp[j], dp[i] + num[j]);         indeg[j]--;         if (indeg[j] == 0) que.push(j);       }     }     int ans = *max_element(dp.begin(), dp.end());     cout << ans << endl;     return 0;   }   