func_code_string: #include <bits/stdc++.h>   using namespace std;   const int dx[] = {0, -1, 0, 1, -1, -1, 1, 1};   const int dy[] = {1, 0, -1, 0, 1, -1, 1, -1};   int n, pre = 0;   int a[1005], b[1005], p[1005];   vector<int> num;   bool vis[1005];   bool valid() {     int na = 0;     set<int> st;     for (int j = 0; j < n; ++j) {       if (a[j] == p[j]) ++na;       st.insert(p[j]);     }     return ((st.size()) == n && na == n - 1);   }   int main() {     int v;     scanf( %d , &n);     for (int i = 0; i < n; ++i) scanf( %d , &a[i]);     for (int i = 0; i < n; ++i) {       scanf( %d , &b[i]);       p[i] = b[i];       if (vis[p[i]]) v = p[i];       vis[p[i]] = 1;     }     vis[v] = 0;     for (int i = 0; i < n; ++i)       if (b[i] == v) num.push_back(i);     int tmp1 = p[num[0]], tmp2 = p[num[1]];     for (int j = 1; j <= n; ++j) {       if (!vis[j]) {         vis[j] = 1;         p[num[0]] = j;         for (int k = 1; k <= n; ++k) {           if (!vis[k]) {             vis[k] = 1;             p[num[1]] = k;             break;           }         }         if (valid())           break;         else {           vis[p[num[0]]] = vis[p[num[1]]] = 0;           p[num[0]] = tmp1;           p[num[1]] = tmp2;         }       }     }     for (int i = 0; i < n; ++i) printf( %d  , p[i]);     return 0;   }   