func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18;   const long long MOD = 1e9 + 7;   const long long mod = 998244353;   const long long mxN = 1e6;   void fileio() {}   vector<long long> v[mxN];   vector<long long> vis(mxN);   long long nd;   void dfs(long long x, long long p) {     vis[x] = 1;     for (auto i : v[x]) {       if (i == p) continue;       if (!vis[i])         dfs(i, x);       else         nd = x;     }   }   void solve() {     long long n;     cin >> n;     vector<long long> a(n);     for (long long i = 0; i < n; i++) cin >> a[i];     ;     for (long long i = 0; i < n; i++) {       v[i + 1].push_back(a[i]);       v[a[i]].push_back(i + 1);     }     vector<long long> v;     for (long long i = 1; i < n + 1; i++) {       if (vis[i]) continue;       nd = i;       dfs(i, -1);       v.push_back(nd);     }     long long ans = v.size() - 1;     long long root = -1;     for (long long i = 0; i < v.size(); i++) {       if (a[v[i] - 1] == v[i]) {         root = v[i];         break;       }     }     if (root == -1) {       ans++;       a[v[0] - 1] = v[0];       root = v[0];     }     for (long long i = 0; i < v.size(); i++) a[v[i] - 1] = root;     cout << ans <<   n ;     for (long long i = 0; i < a.size(); i++) cout << a[i] <<    ;     cout <<   n ;     ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     fileio();     long long tc = 1;     while (tc--) solve();   }   