func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, a[100005] = {0}, b[100005] = {0}, t, j, i, rn = 0, r[100005] = {0},          dis[100005] = {0};   vector<int> v;   vector<int> ht;   int main() {     scanf( %d , &n);     for (i = 1; i <= n; i++) {       scanf( %d , &a[i]);       if (a[i] == 1) ht.push_back(i);     }     for (i = 1; i <= n; i++) {       scanf( %d , &b[i]);       dis[b[i]]++;     }     for (i = 0; i < ht.size(); i++) {       v.clear();       v.push_back(ht[i]);       while (1) {         t = v.size();         if (b[v[t - 1]] == 0) {           break;         }         if (dis[b[v[t - 1]]] == 1)           v.push_back(b[v[t - 1]]);         else           break;       }       if (rn < v.size()) {         rn = v.size();         for (j = 0; j < rn; j++) r[j] = v[j];       }     }     printf( %d n , rn);     for (i = rn - 1; i >= 0; i--) printf( %d%c , r[i], i ?     :   n );     return 0;   }   