func_code_string: #include <bits/stdc++.h>   using namespace std;   typedef struct graph {     list<int> edges[1001];   } graph;   void dfs(graph *g, int i, int group[], int gn) {     for (list<int>::iterator it = g->edges[i].begin(); it != g->edges[i].end();          it++) {       if (group[*it] == -1) {         group[*it] = gn;         dfs(g, *it, group, gn);       }     }   }   void printArray(int arr[], int n) {     for (int i = 1; i <= n; i++) cout << arr[i] <<    ;     cout << endl;   }   int main() {     int n;     graph *g = new graph;     cin >> n;     bool flag = false;     int fin[1001], pref[1001], group[1001];     for (int i = 1; i <= n; i++) cin >> fin[i];     for (int i = 1; i <= n; i++) {       cin >> pref[i];       if (i + pref[i] <= n) {         g->edges[i].push_back(i + pref[i]);         g->edges[i + pref[i]].push_back(i);       }       if (i - pref[i] >= 1) {         g->edges[i].push_back(i - pref[i]);         g->edges[i - pref[i]].push_back(i);       }     }     fill_n(group, n + 1, -1);     int gn = 0;     for (int i = 1; i <= n; i++) {       if (group[i] == -1) {         group[i] = gn;         dfs(g, i, group, gn);         gn++;       }     }     for (int i = 1; i <= n; i++) {       if (group[i] == group[fin[i]]) {       } else {         flag = true;         cout <<  NO  << endl;         break;       }     }     if (!flag) {       cout <<  YES  << endl;     }   }   