1365B Trouble Sort codeforces solution in cpp
by ujjal roy
#include<bits/stdc++.h>
using namespace std;
main()
{
int t,n,i,j,eb,ea;
cin>>t;
while(t--)
{
int czero=0,co=0,s=0;
cin>>n;
int a[n],b[n];
cin>>a[0];
for(i=1;i<n;i++)
{
cin>>a[i];
if(a[i]<a[i-1]) s=1;
}
for(i=0;i<n;i++)
{
cin>>b[i];
if(b[i]==0) czero=1;
if(b[i]==1) co=1;
}
if(s==0) cout<<"Yes"<<endl;
else
{
if(czero==0||co==0) cout<<"No"<<endl;
else cout<<"Yes"<<endl;
}
}
return 0;
}
0 Comments