题意:给你长度为n 的 数组,数组的元素除了值以外还有种类(0,1),你可以进行操作:选择 种类不同的两个 元素然后交换 他们的位置,如果只有一种元素,则 判断是否递减即可
#include <iostream>
using namespace std;
const int N = 5e2+10;
int a[N], b[N];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int T, n;
cin>>T;
while(T--){
cin>>n;
int sum = 0;
for(int i = 0; i < n; ++i){
cin>>a[i];
}
for(int i = 0; i < n; ++i){
cin>>b[i];
sum += b[i];
}
if(sum != 0 && sum != n){
cout<<"Yes\n"; continue;
}
int flag = 0;
for(int i = 1; i < n; ++i){
if(a[i] < a[i-1]){
flag = 1; break;
}
}
if(flag){
cout<<"No\n";
}else{
cout<<"Yes\n";
}
}
return 0;
}