AK_400
2024-11-17 15:49:39
首先
#include<bits/stdc++.h>
using namespace std;
int n,p[200005];
void slv(){
cin>>n;
for(int i=1;i<=n;i++)cin>>p[i];
for(int i=1;i<=n;i++){
if(p[i]==i)continue;
if(p[i+1]==i&&abs(p[i]-p[i+1])==1)swap(p[i],p[i+1]);
else {
cout<<"NO"<<endl;
return;
}
}
cout<<"YES"<<endl;
}
int main(){
int T;cin>>T;while(T--)
slv();
return 0;
}