func_code_string: #include <bits/stdc++.h>   using namespace std;   using ll = long long int;   int ara[200005], dist[200005], ans[200005];   vector<int> even, odd, ad[200005];   bool vis[200005];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, i, j;     cin >> n;     for (i = 1; i <= n; i++) {       cin >> ara[i];       if (ara[i] & 1)         odd.push_back(i);       else         even.push_back(i);       if (i - ara[i] >= 1) ad[i - ara[i]].push_back(i);       if (i + ara[i] <= n) ad[i + ara[i]].push_back(i);     }     memset(dist, -1, sizeof dist);     queue<int> q;     for (i = 0; i < (int)even.size(); i++) {       q.push(even[i]);       dist[even[i]] = 0;       vis[even[i]] = true;     }     while (!q.empty()) {       int u = q.front();       q.pop();       for (i = 0; i < (int)ad[u].size(); i++) {         int v = ad[u][i];         if (!vis[v]) {           vis[v] = true;           q.push(v);           dist[v] = dist[u] + 1;           if (ara[v] & 1) ans[v] = dist[v];         }       }     }     memset(vis, false, sizeof vis);     memset(dist, -1, sizeof dist);     for (i = 0; i < (int)odd.size(); i++) {       q.push(odd[i]);       dist[odd[i]] = 0;       vis[odd[i]] = true;     }     while (!q.empty()) {       int u = q.front();       q.pop();       for (i = 0; i < (int)ad[u].size(); i++) {         int v = ad[u][i];         if (!vis[v]) {           vis[v] = true;           q.push(v);           dist[v] = dist[u] + 1;           if (ara[v] % 2 == 0) ans[v] = dist[v];         }       }     }     for (i = 1; i <= n; i++) {       if (!ans[i]) ans[i] = -1;       cout << ans[i] <<    ;     }     cout << endl;     return 0;   }   