func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   set<pair<int, int> > topo[2];   vector<int> G[maxn], R[maxn];   int n, m, code[maxn], in[maxn], out[maxn];   bool seen[maxn];   void dfs(int node) {     seen[node] = 1;     for (int son : G[node])       if (!seen[son]) dfs(son);     topo[code[node]].insert({out[node], node});   }   int process() {     int answer = 0;     while (!topo[1].empty()) {       answer++;       for (int i = 0; i < 2; i++) {         while (!topo[i].empty() && topo[i].begin()->first == 0) {           auto aux = *topo[i].begin();           topo[i].erase(topo[i].begin());           for (int son : R[aux.second]) {             topo[code[son]].erase({out[son], son});             out[son]--;             topo[code[son]].insert({out[son], son});           }         }       }     }     return answer;   }   int main() {     ios::sync_with_stdio(false);     int x, y;     cin >> n >> m;     for (int i = 1; i <= n; i++) cin >> code[i];     for (int i = 1; i <= m; i++) {       cin >> x >> y;       x++;       y++;       G[x].push_back(y);       R[y].push_back(x);       in[y]++;       out[x]++;     }     for (int i = 1; i <= n; i++)       if (in[i] == 0) dfs(i);     cout << process();     return 0;   }   