#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = 5010;
int a[N],b[N];
int cnta[N],cntb[N];
void solve()
{
int n;cin>>n;
for(int i=1;i<=n;i++)cin>>a[i],cnta[a[i]]++;
for(int i=1;i<=n;i++)cin>>b[i],cntb[b[i]]++;
for(int i=0;i<=5000;i++)
if(cnta[i]!=cntb[i]){cout<<"No"<<'\n';return ;}
for(int i=0;i<=5000;i++)if(cnta[i]>=2){cout<<"Yes"<<'\n';return ;}
int sa=0,sb=0;
for(int i=1;i<=n;i++)
for(int j=i+1;j<=n;j++)
{
if(a[i]>a[j])sa++;
if(b[i]>b[j])sb++;
}
if(sa%2==sb%2)cout<<"Yes"<<'\n';
else cout<<"No"<<'\n';
}
signed main()
{
int T;T=1;
while(T--)solve();
}
|