wssbaaaaa
cf1638A
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> piii;
int tt,n,i,j;
const int N=1e5+10;
int a[N];
void sove(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
for(i=1;i<=n;i++){
if(a[i]!=i){
for(j=i+1;j<=n;j++){
if(a[j]==i)break;
}
reverse(a+i,a+j+1);
break;
}
}
for(int i=1;i<=n;i++)cout<<a[i]<<" ";
cout<<endl;
}
int main(){
cin>>tt;
while(tt--){
sove();
}
return 0;
}
无语到家了
#include<bits/stdc++.h>
using namespace std;
int tt,n;
const int N=1e5+10;
int a[N];
void sove(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
for(int i=1;i<=n;i++){
if(a[i]!=i){
for(int j=i+1;j<=n;j++){
if(a[j]==i){
reverse(a+i,a+j+1);
}
}
break;
}
}
for(int i=1;i<=n;i++)cout<<a[i]<<" ";
cout<<endl;
}
int main(){
cin>>tt;
while(tt--){
sove();
}
return 0;
}
达咩达咩达咩达咩达咩达咩达咩
#include<bits/stdc++.h>
using namespace std;
int tt,n;
const int N=1e5+10;
int a[N];
void sove(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
for(int i=1;i<=n;i++)
if(a[i]!=i)
for(int j=i+1;j<=n;j++){
if(a[j]==i)reverse(a+i,a+j+1);
}
for(int i=1;i<=n;i++)cout<<a[i]<<" ";
cout<<endl;
}
int main(){
cin>>tt;
while(tt--){
sove();
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
vector <int> v0,v1;
int a[n];for(auto &h:a) {cin>>h;if(h&1) v1.push_back(h); else v0.push_back(h);}
vector <int> v00=v0,v10=v1;
sort(v00.begin(),v00.end());sort(v10.begin(),v10.end());
cout<<((v00==v0 && v10==v1) ? "YES" : "NO")<<'\n';
}
return 0;
}
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
int t; cin >> t;
while (t--) {
int n; cin >> n;
bool yes = true;
int a0 = 0, a1 = 0;
while (n--) {
int a; cin >> a;
if (a % 2 == 0) {
if (a0 > a)
yes = false;
else
a0 = a;
} else {
if (a1 > a)
yes = false;
else
a1 = a;
}
}
cout << (yes ? "YES" : "NO") << '\n';
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while(t--)
{
int n;
cin >> n;
vector<int> v[2];
for(int i=1;i<=n;i++)
{
int a;
cin >> a;
v[a&1].push_back(a);
}
if(ranges::is_sorted(v[0])&&ranges::is_sorted(v[1])) cout << "Yes\n";
else cout << "No\n";
}
return 0;
}
#include <stdio.h>
#include <vector>
std::vector<int> V1,V2;
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
V1.clear();
V2.clear();
int a;
scanf("%d",&a);
for(int i=1;i<=a;i++)
{
int b;
scanf("%d",&b);
if(b%2==1) V1.push_back(b);
else V2.push_back(b);
}
int control = 0;
for(int i=1;i<V1.size();i++) if(V1[i-1]>V1[i]) control = 1;
for(int i=1;i<V2.size();i++) if(V2[i-1]>V2[i]) control = 1;
printf("%s\n",control==1?"No":"Yes");
}
}
达咩达咩达咩达咩达咩达咩达咩
#include<bits/stdc++.h>
using namespace std;
int tt,n;
const int N=510;
int a[N],b[N];
int sove(){
bool f;
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
b[i]=a[i];
}
sort(b,b+n);
for(int i=0;i<n-1;i++){
if(a[i]>a[i+1]){
if((a[i]+a[i+1])%2)swap(a[i],a[i+1]);
}
}
for(int i=0;i<n;i++)if(a[i]!=b[i])f=0;
else f=1;
return f;
}
int main(){
cin>>tt;
while(tt--){
if(sove()==1)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}