Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #include<ext/pb_ds/assoc_container.hpp>
- #include<ext/pb_ds/tree_policy.hpp>
- using namespace std;
- using namespace __gnu_pbds;
- #define pb push_back
- #define ll long long
- #define pii pair<int,int>
- #define pll pair<ll,ll>
- #define MaxN 201007
- #define INF 1e9
- #define INFL 1e18
- #define PI acos(-1)
- #define mp make_pair
- typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
- //const int fx[]= {+1,-1,+0,+0};
- //const int fy[]= {+0,+0,+1,-1};
- //const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1}; // Kings Move
- //const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move
- //const int fx[]={-2, -2, -1, -1, 1, 1, 2, 2}; // Knights Move
- //const int fy[]={-1, 1, -2, 2, -2, 2, -1, 1}; // Knights Move
- int gcd(int a, int b)
- {
- return b ? gcd(b, a%b) : a;
- }
- ll bigmod(ll b,ll p,ll m)
- {
- ll res=1LL%m;
- ll x=b%m;
- while(p)
- {
- if( p & 1LL )res=(res*x) % m;
- x=(x*x)%m;
- p >>=1LL;
- }
- return res;
- }
- void blurryface()
- {
- int n;
- scanf("%d",&n);
- vector<int>v;
- int arr[n+100];
- for(int i=1;i<=n;i++)
- {
- int x;
- scanf("%d",&x);
- arr[i]=x;
- v.pb(x);
- // scanf("%d",&arr[i]);
- }
- sort(v.begin(),v.end());
- v.erase(unique(v.begin(),v.end()),v.end());
- for(int i=1;i<=n;i++)
- {
- arr[i]=upper_bound(v.begin(),v.end(),arr[i])-v.begin();
- }
- // for(int i=1;i<=n;i++)
- // {
- // cout<<arr[i]<<" ";
- // }
- // cout<<endl;
- // cout<<endl;
- if(n==1)
- {
- printf("YES\n");
- //cout<<"YES"<<endl;
- return;
- }
- else if(n==2)
- {
- if(arr[1]>arr[2])
- {
- printf("NO\n");
- // cout<<"NO"<<endl;
- }
- else
- {
- printf("YES\n");
- // cout<<"YES"<<endl;
- }
- return;
- }
- else
- {
- for(int i=1;i<=n;i++)
- {
- if((i%2)!=(arr[i]%2))
- {
- printf("NO\n");//<<endl;
- return;
- }
- }
- printf("YES\n");
- return;
- }
- }
- int main()
- {
- // #ifndef ONLINE_JUDGE
- // freopen("input.txt","r",stdin);
- //freopen("output.txt","w",stdout);
- // #endif
- //ios_base::sync_with_stdio(false);
- //cin.tie(NULL);
- int t;
- scanf("%d",&t);
- while(t--)
- {
- blurryface();
- }
- //#ifdef LOCAL_DEFINE
- // cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
- // #endif
- ///Before submit=>
- /// *check for integer overflow,array bounds
- /// *check for n=1
- }
Advertisement
Add Comment
Please, Sign In to add comment