Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int n,i,a[1000000],kol[1000000],b[1000000];
- int main()
- {
- cin >> n;
- for(i=1;i<=n;i++)
- {
- cin >> a[i];
- kol[a[i]]++;
- }
- for (i=1;i<=n;i++)
- cin >> b[i];
- int p1,p2;
- for (i=1;i<=n;i++)
- {
- if(kol[i]==2) p1=i;
- if(kol[i]==0) p2=i;
- }
- for (i=1;i<=n;i++)
- if(a[i]==p1)
- {
- a[i]=p2;
- int f;
- f==0;
- for (int j=1;j<=n;j++)
- if (a[j]!=b[j]) f++;
- if (f==1)
- {
- for (int j=1;j<=n;j++)
- cout << a[j] << " ";
- exit;
- }
- a[i]=p1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement